(final String level, Object msg, Throwable cause)
| 45 | } |
| 46 | |
| 47 | private void log(final String level, Object msg, Throwable cause) { |
| 48 | assert level != null; |
| 49 | assert msg != null; |
| 50 | |
| 51 | if (io == null) { |
| 52 | synchronized (Logger.class) { |
| 53 | if (io == null) { |
| 54 | io = new IO(); |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | // Allow the msg to be a Throwable, and handle it properly if no cause is given |
| 60 | if (cause == null) { |
| 61 | if (msg instanceof Throwable) { |
| 62 | cause = (Throwable) msg; |
| 63 | msg = cause.getMessage(); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | if (io.ansiSupported) { |
| 68 | logWithAnsi(level, msg); |
| 69 | } else { |
| 70 | logDefault(level, msg); |
| 71 | } |
| 72 | |
| 73 | if (cause != null) { |
| 74 | cause.printStackTrace(io.out); |
| 75 | } |
| 76 | |
| 77 | io.flush(); |
| 78 | } |
| 79 | |
| 80 | private void logDefault(String level, Object msg) { |
| 81 | io.out.println(level + " [" + name + "] " + msg); |
no test coverage detected