Skip to content

Commit

Permalink
Use platform-dependant line separator instead of hardcoded '\n'.
Browse files Browse the repository at this point in the history
Fixes logging to file for Windows.

Use System.getProperty() instead of internal JDK api.

Signed-off-by: Daniel Davison <daniel.jj.davison@gmail.com>
  • Loading branch information
sdimkov authored and ddavison committed Oct 28, 2015
1 parent 1cde3ee commit d60bac1
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public class TerseFormatter extends Formatter {
*/
private static final String SUFFIX = " - ";

/**
* Line separator string. This is the value of the line.separator
* property at the moment that the TerseFormatter was created.
*/
private final String lineSeparator = System.getProperty("line.separator");

/*
* DGF - These have to be compile time constants to be used with switch
*/
Expand Down Expand Up @@ -83,7 +89,7 @@ public synchronized String format(final LogRecord record) {
buffer.append(record.getLoggerName());
}
buffer.append(SUFFIX);
buffer.append(formatMessage(record)).append('\n');
buffer.append(formatMessage(record)).append(lineSeparator);
if (record.getThrown() != null) {
final StringWriter trace = new StringWriter();
record.getThrown().printStackTrace(new PrintWriter(trace));
Expand Down

0 comments on commit d60bac1

Please sign in to comment.