1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package net.sourceforge.acelogger.formatter;
16
17 import net.sourceforge.acelogger.LogEvent;
18 import net.sourceforge.acelogger.constants.FormatterConstants;
19 import net.sourceforge.acelogger.interpolator.JavaTextFormatInterpolator;
20
21
22
23
24
25
26
27
28
29 public class SimpleFormatter extends BaseFormatter {
30
31
32
33
34 private static final String LOG_ENTRY = "{0,date,yyyy-MM-dd HH:mm:ss,SSS} [{1}] ({2}) - {3}"
35 + FormatterConstants.NEW_LINE;
36
37
38
39
40
41
42
43
44 public SimpleFormatter(String identifier) {
45 super(identifier, JavaTextFormatInterpolator.getInstance());
46 }
47
48
49 public String formatLogCall(LogEvent call) {
50 String formattedCall = "";
51 if (call != null) {
52 String formattedMessage = formatMessage(call.getMessage(), call.getMessageParameters());
53 String stackTraceLikeName = call.getLocation().getStackTraceLikeName();
54 if (stackTraceLikeName.length() == 0) {
55 stackTraceLikeName = "Source not found";
56 }
57 formattedCall = formatMessage(LOG_ENTRY, call.getCallTime(), call.getLevel(),
58 stackTraceLikeName, formattedMessage);
59 formattedCall = formattedCall.concat(formatStackTrace(call.getCause()));
60 }
61 return formattedCall;
62 }
63
64 }