1
package org.jaudiotagger.logging;
3
import java.io.PrintWriter;
4
import java.io.StringWriter;
5
import java.text.SimpleDateFormat;
7
import java.util.logging.Formatter;
8
import java.util.logging.LogRecord;
11
* For Formatting log output
13
* <p>This is not required by jaudiotagger, but its advantage over the default formatter is that all the format for a log
14
* entry is on one line, making it much easier to read. To use this formatter with your code edit loggin.properties
15
* within your jre/lib folder and modify as follows
16
* e.g java.util.logging.ConsoleHandler.formatter = org.jaudiotagger.logging.LogFormatter </p>
18
public final class LogFormatter extends Formatter
20
private boolean isObsfucated = false;
21
public static final String ACTION_PERFORMED = "actionPerformed";
23
// Line separator string. This is the value of the line.separator
24
// property at the moment that the SimpleFormatter was created.
25
private final String lineSeparator = (String) java.security.AccessController.doPrivileged(new sun.security.action.
26
GetPropertyAction("line.separator"));
28
private final SimpleDateFormat sfDateOut = new SimpleDateFormat("dd/MM/yyyy HH.mm.ss:");
29
private final Date date = new Date();
36
public final String format(final LogRecord record)
38
final StringBuffer sb = new StringBuffer();
40
date.setTime(record.getMillis());
42
sb.append(sfDateOut.format(date));
46
if (record.getSourceClassName() != null)
48
recordName = record.getSourceClassName() + ":" + record.getSourceMethodName();
52
recordName = record.getLoggerName() + ":";
54
if (recordName != null)
56
sb.append(recordName);
59
final String message = formatMessage(record);
60
sb.append(record.getLevel().getLocalizedName());
63
sb.append(lineSeparator);
65
if (record.getThrown() != null)
69
final StringWriter sw = new StringWriter();
70
final PrintWriter pw = new PrintWriter(sw);
71
record.getThrown().printStackTrace(pw);
73
sb.append(sw.toString());
82
public static final String IDENT = "$Id: LogFormatter.java,v 1.12 2009/11/12 15:42:59 paultaylor Exp $";
1
package org.jaudiotagger.logging;
3
import java.io.PrintWriter;
4
import java.io.StringWriter;
5
import java.text.SimpleDateFormat;
7
import java.util.logging.Formatter;
8
import java.util.logging.LogRecord;
11
* For Formatting log output
13
* <p>This is not required by jaudiotagger, but its advantage over the default formatter is that all the format for a log
14
* entry is on one line, making it much easier to read. To use this formatter with your code edit loggin.properties
15
* within your jre/lib folder and modify as follows
16
* e.g java.util.logging.ConsoleHandler.formatter = org.jaudiotagger.logging.LogFormatter </p>
18
public final class LogFormatter extends Formatter
20
private boolean isObsfucated = false;
21
public static final String ACTION_PERFORMED = "actionPerformed";
23
// Line separator string. This is the value of the line.separator
24
// property at the moment that the SimpleFormatter was created.
25
private final String lineSeparator = (String) java.security.AccessController.doPrivileged(new sun.security.action.
26
GetPropertyAction("line.separator"));
28
private final SimpleDateFormat sfDateOut = new SimpleDateFormat("dd/MM/yyyy HH.mm.ss:");
29
private final Date date = new Date();
36
public final String format(final LogRecord record)
38
final StringBuffer sb = new StringBuffer();
40
date.setTime(record.getMillis());
42
sb.append(sfDateOut.format(date));
46
if (record.getSourceClassName() != null)
48
recordName = record.getSourceClassName() + ":" + record.getSourceMethodName();
52
recordName = record.getLoggerName() + ":";
54
if (recordName != null)
56
sb.append(recordName);
59
final String message = formatMessage(record);
60
sb.append(record.getLevel().getLocalizedName());
63
sb.append(lineSeparator);
65
if (record.getThrown() != null)
69
final StringWriter sw = new StringWriter();
70
final PrintWriter pw = new PrintWriter(sw);
71
record.getThrown().printStackTrace(pw);
73
sb.append(sw.toString());
82
public static final String IDENT = "$Id: LogFormatter.java 836 2009-11-12 15:44:07Z paultaylor $";