src/main/java/org/apache/sling/scripting/core/impl/LogWriter.java [48:128]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        this.logger = logger;
        this.lineBuffer = new StringBuilder();
    }

    /**
     * Writes the character to the internal buffer unless the character is a CR
     * or LF in which case the buffer is written to the logger as an error
     * message.
     */
    @Override
    public void write(int c) {
        if (c == '\n' || c == '\r') {
            flush();
        } else {
            synchronized (lineBuffer) {
                lineBuffer.append((char) c);
            }
        }
    }

    /**
     * Writes the indicated characters to the internal buffer, flushing the
     * buffer on any occurrence of a CR of LF.
     */
    @Override
    public void write(char[] cbuf, int off, int len) {
        int i = off;
        for (int n = 0; n < len; n++, i++) {
            char c = cbuf[i];

            // if CR/LF flush the line
            if (c == '\n' || c == '\r') {

                // append upto the CR/LF
                int subLen = i - off;
                if (subLen > 0) {
                    synchronized (lineBuffer) {
                        lineBuffer.append(cbuf, off, subLen);
                    }
                }

                // and flush
                flush();

                // new offset is after the CR/LF
                off = i + 1;
            }
        }

        // remaining data in the buffer is just appended
        if (off < i) {
            synchronized (lineBuffer) {
                lineBuffer.append(cbuf, off, i - off);
            }
        }
    }

    /**
     * Writes any data conained in the buffer to the logger as an error message.
     */
    @Override
    public void flush() {

        String message;
        synchronized (lineBuffer) {
            if (lineBuffer.length() == 0) {
                return;
            }
            message = lineBuffer.toString();
            lineBuffer.setLength(0);
        }

        logger.error(message);
    }

    /**
     * Just calls {@link #flush()}
     */
    @Override
    public void close() {
        flush();
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



src/main/java/org/apache/sling/scripting/core/impl/bundled/LogWriter.java [44:124]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        this.logger = logger;
        this.lineBuffer = new StringBuilder();
    }

    /**
     * Writes the character to the internal buffer unless the character is a CR
     * or LF in which case the buffer is written to the logger as an error
     * message.
     */
    @Override
    public void write(int c) {
        if (c == '\n' || c == '\r') {
            flush();
        } else {
            synchronized (lineBuffer) {
                lineBuffer.append((char) c);
            }
        }
    }

    /**
     * Writes the indicated characters to the internal buffer, flushing the
     * buffer on any occurrence of a CR of LF.
     */
    @Override
    public void write(char[] cbuf, int off, int len) {
        int i = off;
        for (int n = 0; n < len; n++, i++) {
            char c = cbuf[i];

            // if CR/LF flush the line
            if (c == '\n' || c == '\r') {

                // append upto the CR/LF
                int subLen = i - off;
                if (subLen > 0) {
                    synchronized (lineBuffer) {
                        lineBuffer.append(cbuf, off, subLen);
                    }
                }

                // and flush
                flush();

                // new offset is after the CR/LF
                off = i + 1;
            }
        }

        // remaining data in the buffer is just appended
        if (off < i) {
            synchronized (lineBuffer) {
                lineBuffer.append(cbuf, off, i - off);
            }
        }
    }

    /**
     * Writes any data contained in the buffer to the logger as an error message.
     */
    @Override
    public void flush() {

        String message;
        synchronized (lineBuffer) {
            if (lineBuffer.length() == 0) {
                return;
            }
            message = lineBuffer.toString();
            lineBuffer.setLength(0);
        }

        logger.error(message);
    }

    /**
     * Just calls {@link #flush()}
     */
    @Override
    public void close() {
        flush();
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



