FileDocCategorySizeDatePackage
LogFormatter.javaAPI DocJaudiotagger 2.0.42732Thu Apr 28 14:55:18 BST 2011org.jaudiotagger.logging

LogFormatter

public final class LogFormatter extends Formatter
For Formatting log output

This is not required by jaudiotagger, but its advantage over the default formatter is that all the format for a log entry is on one line, making it much easier to read. To use this formatter with your code edit loggin.properties within your jre/lib folder and modify as follows e.g java.util.logging.ConsoleHandler.formatter = org.jaudiotagger.logging.LogFormatter

Fields Summary
private boolean
isObsfucated
public static final String
ACTION_PERFORMED
private final String
lineSeparator
private final SimpleDateFormat
sfDateOut
private final Date
date
public static final String
IDENT
Constructors Summary
public LogFormatter()


     
    

    
Methods Summary
public final java.lang.Stringformat(java.util.logging.LogRecord record)

        final StringBuffer sb = new StringBuffer();

        date.setTime(record.getMillis());

        sb.append(sfDateOut.format(date));

        String recordName;

        if (record.getSourceClassName() != null)
        {
            recordName = record.getSourceClassName() + ":" + record.getSourceMethodName();
        }
        else
        {
            recordName = record.getLoggerName() + ":";
        }
        if (recordName != null)
        {
            sb.append(recordName);
            sb.append(":");
        }
        final String message = formatMessage(record);
        sb.append(record.getLevel().getLocalizedName());
        sb.append(": ");
        sb.append(message);
        sb.append(lineSeparator);

        if (record.getThrown() != null)
        {
            try
            {
                final StringWriter sw = new StringWriter();
                final PrintWriter pw = new PrintWriter(sw);
                record.getThrown().printStackTrace(pw);
                pw.close();
                sb.append(sw.toString());
            }
            catch (Exception ex)
            {
            }
        }
        return sb.toString();