Class: JLogger::RootLogger
- Inherits:
-
Object
- Object
- JLogger::RootLogger
show all
- Includes:
- Simple
- Defined in:
- lib/jlogger.rb
Constant Summary
collapse
- PATTERN =
RJack::Logback::PatternLayout.new("%-5level\t%date{HH:mm:ss}\t%5r\t%-30logger\t%msg\n")
Constants included
from Simple
Simple::LEVELS, Simple::Level
Instance Method Summary
collapse
Methods included from Simple
included, #log, method_missing
Constructor Details
Returns a new instance of RootLogger.
142
143
144
145
146
|
# File 'lib/jlogger.rb', line 142
def initialize
self.class._logobject = RJack::Logback.root
self.class._slflogger = self.class._logobject.jlogger
RJack::Logback.root.jlogger.detachAppender('console')
end
|
Instance Method Details
#debug(*args) ⇒ Object
150
151
152
|
# File 'lib/jlogger.rb', line 150
def debug *args
log.debug *args
end
|
#debug? ⇒ Boolean
167
168
169
|
# File 'lib/jlogger.rb', line 167
def debug?
return log.debug_enabled?
end
|
#error(*args) ⇒ Object
162
163
164
|
# File 'lib/jlogger.rb', line 162
def error *args
log.error *args
end
|
#error? ⇒ Boolean
179
180
181
|
# File 'lib/jlogger.rb', line 179
def error?
return log.error_enabled?
end
|
#info(*args) ⇒ Object
154
155
156
|
# File 'lib/jlogger.rb', line 154
def info *args
log.info *args
end
|
#info? ⇒ Boolean
171
172
173
|
# File 'lib/jlogger.rb', line 171
def info?
return log.info_enabled?
end
|
#loglevel=(level) ⇒ Object
Set the log level Why do I need to redefine this here? self.class.loglevel = level fails with method not found.s
187
188
189
190
191
192
193
194
195
|
# File 'lib/jlogger.rb', line 187
def loglevel= level
self.class.createlogger unless self.class._logobject
level = level.to_s.downcase.to_sym
unless JLogger::Simple::LEVELS.has_key? level
raise ArgumentError, "'#{level}' is an invalid loglevel"
end
self.class._logobject.level = JLogger::Simple::LEVELS[level]
end
|
#startConsole(pattern = nil) ⇒ Object
197
198
199
200
201
202
203
204
205
|
# File 'lib/jlogger.rb', line 197
def startConsole pattern = nil
return if RJack::Logback.root.jlogger.getAppender('jlconsole')
jlconsole = RJack::Logback::ConsoleAppender.new do |a|
a.target = "System.err"
a.name = 'jlconsole'
a.layout = pattern || PATTERN
end
RJack::Logback.root.add_appender( jlconsole )
end
|
#startFile(file, pattern = nil) ⇒ Object
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
# File 'lib/jlogger.rb', line 213
def startFile file, pattern = nil
id = nil
mod = nil
if file.is_a? String
id = file
mod = RJack::Logback::FileAppender
else
raise ArgumentError, "#{file} is not a valid target for file logging. Must be a filename"
end
return if RJack::Logback.root.jlogger.getAppender(id)
app = mod.new(file) do |a|
a.name = id
a.layout = pattern || PATTERN
end
RJack::Logback.root.add_appender( app )
end
|
#stopConsole ⇒ Object
207
208
209
|
# File 'lib/jlogger.rb', line 207
def stopConsole
RJack::Logback.root.jlogger.detachAppender('jlconsole')
end
|
#stopFile(file) ⇒ Object
238
239
240
241
242
243
244
245
246
247
|
# File 'lib/jlogger.rb', line 238
def stopFile file
if file.is_a? String
id = file
else
raise ArgumentError, "#{file} is not a valid target for file logging"
end
RJack::Logback.root.jlogger.detachAppender(id)
end
|
#warn(*args) ⇒ Object
158
159
160
|
# File 'lib/jlogger.rb', line 158
def warn *args
log.warn *args
end
|
#warn? ⇒ Boolean
175
176
177
|
# File 'lib/jlogger.rb', line 175
def warn?
return log.warn_enabled?
end
|