public SlimPipeSocket() throws IOException { // preserve original streams this.stdout = System.out; this.stderr = System.err; this.stdin = System.in; // bind System.stdout/System.stderr to original stderr System.setOut(new PrintStream(new LoggingOutputStream(this.stderr, STDOUT_PREFIX), true, FileUtil.CHARENCODING)); System.setErr(new PrintStream(new LoggingOutputStream(this.stderr, STDERR_PREFIX), true, FileUtil.CHARENCODING)); LOG.log(Level.FINER, "Creating Slim Server with pipe socket."); }
/** * upon flush() write the existing contents of the OutputStream to the logger * as a log record. * * @throws java.io.IOException * in case of error */ @Override public void flush() throws IOException { String record; synchronized (this) { super.flush(); record = this.toString(); super.reset(); } if (record.length() == 0 || record.equals(lineSeparator)) { // avoid empty records return; } // Prefix each new line with: newline + level + DOT + ":" record = record.replace("\n", "\n" + level + SlimPipeSocket.FOLLOWING_LINE_PREFIX); // Prefix first line with: level + SPACE + ":" logger.println(level + SlimPipeSocket.FIRST_LINE_PREFIX + record); }
/** * upon flush() write the existing contents of the OutputStream to the logger * as a log record. * * @throws java.io.IOException * in case of error */ @Override public void flush() throws IOException { String record; synchronized (this) { super.flush(); record = this.toString(); super.reset(); } if (record.length() == 0 || record.equals(lineSeparator)) { // avoid empty records return; } // Prefix each new line with: newline + level + DOT + ":" record = record.replace("\n", "\n" + level + SlimPipeSocket.FOLLOWING_LINE_PREFIX); // Prefix first line with: level + SPACE + ":" logger.println(level + SlimPipeSocket.FIRST_LINE_PREFIX + record); }
public SlimPipeSocket() throws IOException { // preserve original streams this.stdout = System.out; this.stderr = System.err; this.stdin = System.in; // bind System.stdout/System.stderr to original stderr System.setOut(new PrintStream(new LoggingOutputStream(this.stderr, STDOUT_PREFIX), true, FileUtil.CHARENCODING)); System.setErr(new PrintStream(new LoggingOutputStream(this.stderr, STDERR_PREFIX), true, FileUtil.CHARENCODING)); LOG.log(Level.FINER, "Creating Slim Server with pipe socket."); }