Class: LogKernel::Logger
- Inherits:
-
Object
- Object
- LogKernel::Logger
- Includes:
- Level
- Defined in:
- lib/logutils/logger.rb
Constant Summary
Constants included from Level
LogKernel::Level::ALL, LogKernel::Level::DEBUG, LogKernel::Level::ERROR, LogKernel::Level::FATAL, LogKernel::Level::INFO, LogKernel::Level::OFF, LogKernel::Level::UNKNOWN, LogKernel::Level::WARN
Instance Attribute Summary collapse
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
Class Method Summary collapse
Instance Method Summary collapse
- #debug(msg) ⇒ Object
- #error(msg) ⇒ Object
- #fatal(msg) ⇒ Object
- #info(msg) ⇒ Object
-
#initialize ⇒ Logger
constructor
A new instance of Logger.
-
#level=(key) ⇒ Object
NB: use :debug, :info, :warn, :error, etc as argument.
- #unknown(msg) ⇒ Object
- #warn(msg) ⇒ Object
Constructor Details
permalink #initialize ⇒ Logger
Returns a new instance of Logger.
128 129 130 131 132 133 134 135 |
# File 'lib/logutils/logger.rb', line 128 def initialize @handlers = [] @handlers << STDHANDLER # by default log to console ## todo/check: pass levelno through to handlers? # do we need a "global" levelno in the logger? @levelno = ALL end |
Instance Attribute Details
permalink #handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
137 138 139 |
# File 'lib/logutils/logger.rb', line 137 def handlers @handlers end |
Class Method Details
permalink .[](class_or_name) ⇒ Object
[View source]
120 121 122 |
# File 'lib/logutils/logger.rb', line 120 def self.[]( class_or_name ) STDLOGGER end |
permalink .root ⇒ Object
[View source]
124 125 126 |
# File 'lib/logutils/logger.rb', line 124 def self.root STDLOGGER end |
Instance Method Details
permalink #debug(msg) ⇒ Object
[View source]
150 151 152 |
# File 'lib/logutils/logger.rb', line 150 def debug( msg ) write( Event.new( DEBUG, msg ) ) end |
permalink #error(msg) ⇒ Object
[View source]
162 163 164 |
# File 'lib/logutils/logger.rb', line 162 def error( msg ) write( Event.new( ERROR, msg ) ) end |
permalink #fatal(msg) ⇒ Object
[View source]
166 167 168 |
# File 'lib/logutils/logger.rb', line 166 def fatal( msg ) write( Event.new( FATAL, msg ) ) end |
permalink #info(msg) ⇒ Object
[View source]
154 155 156 |
# File 'lib/logutils/logger.rb', line 154 def info( msg ) write( Event.new( INFO, msg ) ) end |
permalink #level=(key) ⇒ Object
NB: use :debug, :info, :warn, :error, etc as argument
if invalid argument gets passed in, level gets set to UNKNOWN
145 146 147 |
# File 'lib/logutils/logger.rb', line 145 def level=( key ) @levelno = LEVEL_HASH.fetch( key, UNKNOWN ) end |
permalink #unknown(msg) ⇒ Object
[View source]
170 171 172 |
# File 'lib/logutils/logger.rb', line 170 def unknown( msg ) write( Event.new( UNKNOWN, msg ) ) end |
permalink #warn(msg) ⇒ Object
[View source]
158 159 160 |
# File 'lib/logutils/logger.rb', line 158 def warn( msg ) write( Event.new( WARN, msg ) ) end |