private static OutputChoice computeOutputChoice(String logFile, boolean cacheOutputStream) { if ("System.err".equalsIgnoreCase(logFile)) if (cacheOutputStream) return new OutputChoice(OutputChoiceType.CACHED_SYS_ERR); else return new OutputChoice(OutputChoiceType.SYS_ERR); else if ("System.out".equalsIgnoreCase(logFile)) { if (cacheOutputStream) return new OutputChoice(OutputChoiceType.CACHED_SYS_OUT); else return new OutputChoice(OutputChoiceType.SYS_OUT); } else { try { FileOutputStream fos = new FileOutputStream(logFile); PrintStream printStream = new PrintStream(fos); return new OutputChoice(printStream); } catch (FileNotFoundException e) { Util.report("Could not open [" + logFile + "]. Defaulting to System.err", e); return new OutputChoice(OutputChoiceType.SYS_ERR); } } }
void write(StringBuilder buf, Throwable t) { PrintStream targetStream = CONFIG_PARAMS.outputChoice.getTargetPrintStream(); targetStream.println(buf.toString()); writeThrowable(t, targetStream); targetStream.flush(); }
private static OutputChoice computeOutputChoice(String logFilePath, boolean cacheOutputStream) { if (LOG_ERR.equalsIgnoreCase(logFilePath)) { if (cacheOutputStream) { return new OutputChoice(OutputChoice.OutputChoiceType.CACHED_SYS_ERR); } else { return new OutputChoice(OutputChoice.OutputChoiceType.SYS_ERR); } } else if (LOG_OUT.equalsIgnoreCase(logFilePath)) { if (cacheOutputStream) { return new OutputChoice(OutputChoice.OutputChoiceType.CACHED_SYS_OUT); } else { return new OutputChoice(OutputChoice.OutputChoiceType.SYS_OUT); } } else { return new OutputChoice(OutputChoice.OutputChoiceType.FILE); } }
private void write(StringBuffer buf, Throwable t) { if (CONFIG_PARAMS.outputChoice.outputChoiceType == OutputChoice.OutputChoiceType.FILE) { if (CONFIG_PARAMS.showConsole) { if (null != t) { String stack = " " + LogUtils.stackTraceToString(t); buf.append(stack); System.err.println(buf.toString()); } else { System.out.println(buf.toString()); System.out.flush(); } } if (null != CONFIG_PARAMS.fileRunner) { CONFIG_PARAMS.fileRunner.addToQueue(buf); } } else { PrintStream targetStream = CONFIG_PARAMS.outputChoice.getTargetPrintStream(); targetStream.println(buf.toString()); writeThrowable(t, targetStream); targetStream.flush(); } }
public void init() { // lets set the initialised flag so we don't get replaced later on SimpleLogger.lazyInit(); SimpleLogger.CONFIG_PARAMS = this; super.init(); this.outputChoice = new OutputChoice(out); this.showThreadName = false; } }