1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.jsr168.pluto.services.log;
35
36 import fr.paris.lutece.plugins.jsr168.pluto.LutecePlutoConstant;
37 import fr.paris.lutece.portal.service.util.AppLogService;
38
39 import org.apache.commons.logging.LogFactory;
40
41 import org.apache.pluto.portalImpl.services.log.LogService;
42 import org.apache.pluto.portalImpl.services.log.LoggerImpl;
43 import org.apache.pluto.portalImpl.util.Properties;
44 import org.apache.pluto.services.log.Logger;
45
46
47
48
49
50
51 public class LogServiceImpl extends LogService
52 {
53 private boolean _bIsDebugEnabled;
54 private boolean _bIsInfoEnabled;
55 private boolean _bIsWarnEnabled;
56 private boolean _bIsErrorEnabled;
57
58
59
60
61
62
63 public void init( Properties aProperties )
64 {
65 _bIsDebugEnabled = aProperties.getBoolean( LutecePlutoConstant.CONFIG_SERVICES_LOG_DEBUG_ENABLED,
66 LutecePlutoConstant.CONFIG_SERVICES_LOG_DEBUG_ENABLED_DEFAULT ).booleanValue( );
67 _bIsInfoEnabled = aProperties.getBoolean( LutecePlutoConstant.CONFIG_SERVICES_LOG_INFO_ENABLED,
68 LutecePlutoConstant.CONFIG_SERVICES_LOG_INFO_ENABLED_DEFAULT ).booleanValue( );
69 _bIsWarnEnabled = aProperties.getBoolean( LutecePlutoConstant.CONFIG_SERVICES_LOG_WARN_ENABLED,
70 LutecePlutoConstant.CONFIG_SERVICES_LOG_WARN_ENABLED_DEFAULT ).booleanValue( );
71 _bIsErrorEnabled = aProperties.getBoolean( LutecePlutoConstant.CONFIG_SERVICES_LOG_ERROR_ENABLED,
72 LutecePlutoConstant.CONFIG_SERVICES_LOG_ERROR_ENABLED_DEFAULT ).booleanValue( );
73 }
74
75
76
77
78 public boolean isDebugEnabled( String aComponent )
79 {
80 return _bIsDebugEnabled;
81 }
82
83
84
85
86 public boolean isInfoEnabled( String aComponent )
87 {
88 return _bIsInfoEnabled;
89 }
90
91
92
93
94 public boolean isWarnEnabled( String aComponent )
95 {
96 return _bIsWarnEnabled;
97 }
98
99
100
101
102 public boolean isErrorEnabled( String aComponent )
103 {
104 return _bIsErrorEnabled;
105 }
106
107
108
109
110 public void debug( String aComponent, String aMessage )
111 {
112 AppLogService.debug( aComponent + ": " + aMessage );
113 }
114
115
116
117
118 public void debug( String aComponent, String aMessage, Throwable aThrowable )
119 {
120 AppLogService.debug( aComponent + ": " + aMessage, aThrowable );
121 }
122
123
124
125
126 public void info( String aComponent, String aMessage )
127 {
128 AppLogService.info( aComponent + ": " + aMessage );
129 }
130
131
132
133
134 public void warn( String aComponent, String aMessage )
135 {
136 AppLogService.info( aComponent + ": " + aMessage );
137 }
138
139
140
141
142 public void error( String aComponent, String aMessage, Throwable aThrowable )
143 {
144 AppLogService.error( aComponent + ": " + aMessage, aThrowable );
145 }
146
147
148
149
150 public void error( String aComponent, Throwable aThrowable )
151 {
152 AppLogService.error( aComponent, aThrowable );
153 }
154
155
156 public Logger getLogger( String component )
157 {
158 return new LoggerImpl( LogFactory.getLog( component ) );
159 }
160
161
162 public Logger getLogger( Class klass )
163 {
164 return new LoggerImpl( LogFactory.getLog( klass ) );
165 }
166 }