Module: JLogger::Simple
Constant Summary collapse
- Level =
Java::ch.qos.logback.classic.Level
- LEVELS =
{ # :off => RJack::Logback::OFF, :off => Level::OFF, :trace => TRACE, :debug => DEBUG, :info => INFO, :warn => WARN, :error => ERROR, }
Class Method Summary collapse
-
.included(klass) ⇒ Object
On inclusion, we set up a logger for this class.
- .method_missing(meth, *args) ⇒ Object
Instance Method Summary collapse
-
#log ⇒ Object
The log object.
Class Method Details
.included(klass) ⇒ Object
On inclusion, we set up a logger for this class
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/jlogger.rb', line 84 def self.included klass @root ||= JLogger::RootLogger.new class << klass attr_accessor :_slflogger, :_logobject def createlogger RJack::Logback.root.jlogger.detachAppender('console') @_slflogger = RJack::SLF4J[self] @_logobject = RJack::Logback[@_slflogger.name] @_slflogger = @_logobject.jlogger end def log createlogger unless @_slflogger return @_slflogger end def loglevel= level self.createlogger unless @_slflogger level = level.to_s.downcase.to_sym unless LEVELS.has_key? level raise ArgumentError, "'#{level}' is an invalid loglevel" end @_logobject.level = LEVELS[level] end end end |
.method_missing(meth, *args) ⇒ Object
76 77 78 |
# File 'lib/jlogger.rb', line 76 def self.method_missing(meth, *args) @root.send(meth, *args) end |
Instance Method Details
#log ⇒ Object
The log object. First thing we do is try to get a logger from the class; if we can’t, go ahead and build one
121 122 123 124 125 126 |
# File 'lib/jlogger.rb', line 121 def log unless self.class._slflogger self.class.createlogger end return self.class._slflogger end |