michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: package org.mozilla.gecko.background.common.log.writers; michael@0: michael@0: import java.io.PrintWriter; michael@0: import java.io.StringWriter; michael@0: michael@0: public class StringLogWriter extends LogWriter { michael@0: protected final StringWriter sw; michael@0: protected final PrintLogWriter inner; michael@0: michael@0: public StringLogWriter() { michael@0: sw = new StringWriter(); michael@0: inner = new PrintLogWriter(new PrintWriter(sw)); michael@0: } michael@0: michael@0: public String toString() { michael@0: return sw.toString(); michael@0: } michael@0: michael@0: @Override michael@0: public boolean shouldLogVerbose(String tag) { michael@0: return true; michael@0: } michael@0: michael@0: public void error(String tag, String message, Throwable error) { michael@0: inner.error(tag, message, error); michael@0: } michael@0: michael@0: public void warn(String tag, String message, Throwable error) { michael@0: inner.warn(tag, message, error); michael@0: } michael@0: michael@0: public void info(String tag, String message, Throwable error) { michael@0: inner.info(tag, message, error); michael@0: } michael@0: michael@0: public void debug(String tag, String message, Throwable error) { michael@0: inner.debug(tag, message, error); michael@0: } michael@0: michael@0: public void trace(String tag, String message, Throwable error) { michael@0: inner.trace(tag, message, error); michael@0: } michael@0: michael@0: public void close() { michael@0: inner.close(); michael@0: } michael@0: }