private OutputStream getOutputStream(final String s) {
        return new OutputStream() {

            StringBuffer o = new StringBuffer();
            boolean done = false;

            @Override
            public void write(int b) throws IOException {
                if (b == '\n' && !sync) {
                    synchronized (conf) {
                        System.out.printf("[%s] %s \n", s, o.toString());
                    }
                    o = new StringBuffer();
                }
                o.append((char) b);
            }

            @Override
            public void flush() throws IOException {
                if (!done) {
                    if (sync) {
                        System.out.printf("************* %s **************\n", s);
                    }
                    System.out.printf(o.toString());
                    done = true;
                }
            }
        };
    }