Record what is written to a log file and return it in toString .
| 37 | * Record what is written to a log file and return it in <code>toString</code>. |
| 38 | */ |
| 39 | public class LogRecord implements LogStream { |
| 40 | |
| 41 | private final PrintStream mStream; |
| 42 | |
| 43 | private final ByteArrayOutputStream mByteStream; |
| 44 | |
| 45 | /** |
| 46 | * Creates a new record. |
| 47 | */ |
| 48 | public LogRecord() { |
| 49 | mByteStream = new ByteArrayOutputStream(); |
| 50 | mStream = new PrintStream(mByteStream); |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public void close() { |
| 55 | // do nothing |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public void removeLog() { |
| 60 | //do nothing |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public PrintStream stream() { |
| 65 | return mStream; |
| 66 | } |
| 67 | |
| 68 | @Override |
| 69 | public File file() { |
| 70 | return null; |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public String toString() { |
| 75 | return mByteStream.toString(); |
| 76 | } |
| 77 | } |
| 78 |
nothing calls this directly
no outgoing calls
no test coverage detected