// Path: src/trinidad-rb/java/rb/trinidad/logging/LoggingHelpers.java
// public abstract class LoggingHelpers {
// 
//     public static boolean isContextLogger(final String logger) {
//         if ( logger == null ) return false;
//         if ( ! logger.startsWith("org.apache.catalina.core.ContainerBase.") ) return false;
//         // e.g. org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/foo]
//         // or org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[default]
//         final int end = logger.length() - 1;
//         if ( logger.charAt(end) != ']' ) return false;
//         final int i = logger.lastIndexOf('[') + 1; if ( i <= 0 ) return false;
//         return true;
//     }
// 
//     public static String getContextName(final String logger) {
//         if ( logger == null ) return null;
//         if ( ! logger.startsWith("org.apache.catalina.core.ContainerBase.") ) return null;
//         // e.g. org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/foo]
//         // or org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[default]
//         final int end = logger.length() - 1;
//         if ( logger.charAt(end) != ']' ) return null;
//         final int i = logger.lastIndexOf('[') + 1; if ( i <= 0 ) return null;
//         return logger.substring(i, end);
//     }
// 
//     public static CharSequence formatThrown(final Throwable thrown) {
//         if ( thrown == null ) return null;
//         final StringBuilder buffer = new StringBuilder();
//         formatThrown(thrown, buffer);
//         return buffer;
//     }
// 
//     public static void formatThrown(final Throwable thrown, final StringBuilder buffer) {
//         if ( thrown == null ) return;
//         StringWriter stringWriter = new StringWriter(512);
//         PrintWriter printWriter = new PrintWriter(stringWriter);
//         thrown.printStackTrace(printWriter);
//         printWriter.println();
//         printWriter.close();
//         buffer.append( stringWriter.getBuffer() );
//     }
// 
//     static final String LINE_SEPARATOR = System.getProperty("line.separator");
// 
//     static boolean endsWithLineSeparator(final CharSequence msg) {
//         final int len = msg.length();
//         final String ls = LINE_SEPARATOR;
//         if ( ls != null && len > ls.length() ) {
//             final int end = len - ls.length();
//             return ls.equals( msg.subSequence(end, len) );
//         }
//         return false;
//     }
// 
// }


import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import static rb.trinidad.logging.LoggingHelpers.*;
import java.lang.reflect.Field;
import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
    }

    public DefaultFormatter(DateFormat dateFormat) {
        if ( dateFormat == null ) {
            throw new IllegalArgumentException("no format given");
        }
        this.dateFormat = dateFormat;
    }

    public DateFormat getDateFormat() {
        return dateFormat;
    }

    @Override
    public String format(final LogRecord record) {
        String message = record.getMessage();
        StringBuffer msg = new StringBuffer(32 + 2 + 7 + 1 + message.length());
        Date millis = new Date(record.getMillis());
        synchronized(dateFormat) {
            dateFormat.format(millis, msg, dummyPosition);
        }
        msg.append(' ').append(record.getLevel().getName()).append(':'); // WARNING:
        msg.append(' ').append(formatMessage(record)); // message
        if ( ! endsWithLineSeparator(msg) ) msg.append(LINE_SEPARATOR);
        final CharSequence thrown = formatThrown(record);
        if ( thrown != null ) msg.append(thrown);
        return msg.toString();
    }

    protected CharSequence formatThrown(final LogRecord record) {
// Path: src/trinidad-rb/java/rb/trinidad/logging/LoggingHelpers.java
// public abstract class LoggingHelpers {
// 
//     public static boolean isContextLogger(final String logger) {
//         if ( logger == null ) return false;
//         if ( ! logger.startsWith("org.apache.catalina.core.ContainerBase.") ) return false;
//         // e.g. org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/foo]
//         // or org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[default]
//         final int end = logger.length() - 1;
//         if ( logger.charAt(end) != ']' ) return false;
//         final int i = logger.lastIndexOf('[') + 1; if ( i <= 0 ) return false;
//         return true;
//     }
// 
//     public static String getContextName(final String logger) {
//         if ( logger == null ) return null;
//         if ( ! logger.startsWith("org.apache.catalina.core.ContainerBase.") ) return null;
//         // e.g. org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/foo]
//         // or org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[default]
//         final int end = logger.length() - 1;
//         if ( logger.charAt(end) != ']' ) return null;
//         final int i = logger.lastIndexOf('[') + 1; if ( i <= 0 ) return null;
//         return logger.substring(i, end);
//     }
// 
//     public static CharSequence formatThrown(final Throwable thrown) {
//         if ( thrown == null ) return null;
//         final StringBuilder buffer = new StringBuilder();
//         formatThrown(thrown, buffer);
//         return buffer;
//     }
// 
//     public static void formatThrown(final Throwable thrown, final StringBuilder buffer) {
//         if ( thrown == null ) return;
//         StringWriter stringWriter = new StringWriter(512);
//         PrintWriter printWriter = new PrintWriter(stringWriter);
//         thrown.printStackTrace(printWriter);
//         printWriter.println();
//         printWriter.close();
//         buffer.append( stringWriter.getBuffer() );
//     }
// 
//     static final String LINE_SEPARATOR = System.getProperty("line.separator");
// 
//     static boolean endsWithLineSeparator(final CharSequence msg) {
//         final int len = msg.length();
//         final String ls = LINE_SEPARATOR;
//         if ( ls != null && len > ls.length() ) {
//             final int end = len - ls.length();
//             return ls.equals( msg.subSequence(end, len) );
//         }
//         return false;
//     }
// 
// }


// Path: src/trinidad-rb/java/rb/trinidad/logging/DefaultFormatter.java
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import static rb.trinidad.logging.LoggingHelpers.*;
import java.lang.reflect.Field;
import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

    }

    public DefaultFormatter(DateFormat dateFormat) {
        if ( dateFormat == null ) {
            throw new IllegalArgumentException("no format given");
        }
        this.dateFormat = dateFormat;
    }

    public DateFormat getDateFormat() {
        return dateFormat;
    }

    @Override
    public String format(final LogRecord record) {
        String message = record.getMessage();
        StringBuffer msg = new StringBuffer(32 + 2 + 7 + 1 + message.length());
        Date millis = new Date(record.getMillis());
        synchronized(dateFormat) {
            dateFormat.format(millis, msg, dummyPosition);
        }
        msg.append(' ').append(record.getLevel().getName()).append(':'); // WARNING:
        msg.append(' ').append(formatMessage(record)); // message
        if ( ! endsWithLineSeparator(msg) ) msg.append(LINE_SEPARATOR);
        final CharSequence thrown = formatThrown(record);
        if ( thrown != null ) msg.append(thrown);
        return msg.toString();
    }

    protected CharSequence formatThrown(final LogRecord record) {
        return LoggingHelpers.formatThrown( record.getThrown() );