Mercurial Hosting > luan
annotate src/goodjava/logger/GoodLogger.java @ 1622:b7f8418fb7ba
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 26 Jul 2021 11:51:56 -0600 |
parents | 329197048ff0 |
children |
rev | line source |
---|---|
1448 | 1 package goodjava.logger; |
2 | |
3 import goodjava.logging.Logger; | |
4 | |
5 | |
6 public final class GoodLogger implements Logger { | |
7 public final String name; | |
1450 | 8 public volatile int level; |
9 public volatile Appender appender; | |
1448 | 10 |
1594
329197048ff0
add DailyRollingFileAppender
Franklin Schmidt <fschmidt@gmail.com>
parents:
1450
diff
changeset
|
11 public GoodLogger(String name) { |
1448 | 12 this.name = name; |
13 } | |
14 | |
15 private void log(int level,String msg,Throwable t) { | |
16 if( level < this.level ) | |
17 return; | |
18 LoggingEvent event = new LoggingEvent(this,level,msg,t); | |
19 appender.append(event); | |
20 } | |
21 | |
22 | |
23 @Override public void error(String msg) { | |
24 error(msg,null); | |
25 } | |
26 | |
27 @Override public void error(String msg,Throwable t) { | |
28 log(Level.ERROR,msg,t); | |
29 } | |
30 | |
31 @Override public void warn(String msg) { | |
32 warn(msg,null); | |
33 } | |
34 | |
35 @Override public void warn(String msg,Throwable t) { | |
36 log(Level.WARN,msg,t); | |
37 } | |
38 | |
39 @Override public void info(String msg) { | |
40 info(msg,null); | |
41 } | |
42 | |
43 @Override public void info(String msg,Throwable t) { | |
44 log(Level.INFO,msg,t); | |
45 } | |
46 | |
47 @Override public boolean isInfoEnabled() { | |
48 return isEnabled(Level.INFO); | |
49 } | |
50 | |
51 @Override public void debug(String msg) { | |
52 debug(msg,null); | |
53 } | |
54 | |
55 @Override public void debug(String msg,Throwable t) { | |
56 log(Level.DEBUG,msg,t); | |
57 } | |
58 | |
59 @Override public boolean isDebugEnabled() { | |
60 return isEnabled(Level.DEBUG); | |
61 } | |
62 | |
63 private boolean isEnabled(int level) { | |
1594
329197048ff0
add DailyRollingFileAppender
Franklin Schmidt <fschmidt@gmail.com>
parents:
1450
diff
changeset
|
64 return level >= this.level; |
1448 | 65 } |
66 } |