|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 package org.mozilla.gecko.background.common.log.writers; |
|
6 |
|
7 import java.io.PrintWriter; |
|
8 import java.io.StringWriter; |
|
9 |
|
10 public class StringLogWriter extends LogWriter { |
|
11 protected final StringWriter sw; |
|
12 protected final PrintLogWriter inner; |
|
13 |
|
14 public StringLogWriter() { |
|
15 sw = new StringWriter(); |
|
16 inner = new PrintLogWriter(new PrintWriter(sw)); |
|
17 } |
|
18 |
|
19 public String toString() { |
|
20 return sw.toString(); |
|
21 } |
|
22 |
|
23 @Override |
|
24 public boolean shouldLogVerbose(String tag) { |
|
25 return true; |
|
26 } |
|
27 |
|
28 public void error(String tag, String message, Throwable error) { |
|
29 inner.error(tag, message, error); |
|
30 } |
|
31 |
|
32 public void warn(String tag, String message, Throwable error) { |
|
33 inner.warn(tag, message, error); |
|
34 } |
|
35 |
|
36 public void info(String tag, String message, Throwable error) { |
|
37 inner.info(tag, message, error); |
|
38 } |
|
39 |
|
40 public void debug(String tag, String message, Throwable error) { |
|
41 inner.debug(tag, message, error); |
|
42 } |
|
43 |
|
44 public void trace(String tag, String message, Throwable error) { |
|
45 inner.trace(tag, message, error); |
|
46 } |
|
47 |
|
48 public void close() { |
|
49 inner.close(); |
|
50 } |
|
51 } |