Exemplo n.º 1
0
  private class TerminalOutputStream extends ByteArrayOutputStream {
    private final String separator = System.getProperty("line.separator");

    @Override
    public synchronized void flush() throws IOException {
      super.flush();
      String record = this.toString();
      super.reset();

      if (record.length() > 0 && !record.equals(separator)) {
        jTerminal.print(record);
        jFrame.repaint();
      }
    }
  }
Exemplo n.º 2
0
  private class LoggerOutputStream extends ByteArrayOutputStream {
    private final String separator = System.getProperty("line.separator");
    private final Level level;

    public LoggerOutputStream(Level level) {
      super();
      this.level = level;
    }

    @Override
    public synchronized void flush() throws IOException {
      super.flush();
      String record = this.toString();
      super.reset();

      if (record.length() > 0 && !record.equals(separator)) {
        server.getLogger().logp(level, "LoggerOutputStream", "log" + level, record);
      }
    }
  }