Code example for LogRecord

Methods: getLevel, getLoggerName, getMessage, getMillis, getSourceClassName, getThrown, setMessage

0
     * @return a formatted log record 
     * 
     * @throws AssertionError Should never occur. 
     */ 
    public synchronized String format(final LogRecord record) {
        String logger = record.getLoggerName();
 
        final String recordLevel = record.getLevel().getLocalizedName();
 
        try { 
            buffer.setLength(1);
 
            final Long millis = new Long(record.getMillis() - startMillis);
            writer.write(millis.toString());
            writer.write(" ");
            writer.write(PREFIX);
            writer.write(recordLevel);
            writer.write(SUFFIX);
 
            if (record.getSourceClassName() != null) {
                writer.write(record.getSourceClassName());
            } 
 
            writer.write(" - ");
 
            /* 
             * Now format the message. We will use a line separator made of 
             * the usual EOL ("\r", "\n", or "\r\n", which is plateform 
             * specific) following by some amout of space in order to align 
             * message body. 
             */ 
            writer.setLineSeparator(bodyLineSeparator);
 
            if (record.getMessage() == null) {
                record.setMessage("null");
            } 
 
            writer.write(formatMessage(record));
            writer.setLineSeparator(lineSeparator);
            writer.write('\n');
 
            if (record.getThrown() != null) {
                try { 
                    writer.write(getStackTrace(record.getThrown()));
                } catch (Exception e) {
                    // do not write the exception... 
                } 
            }