Class: Norikra::DummyLogger
Overview
for tests
Constant Summary collapse
- FORMAT_SIMULATED =
LOG_LOG4J_FORMAT = ā%dHH:mm:ss Z [%p] %m%nā LOG_FORMAT = ā%s: %s%sā
"%s [%s] %s\n"
Constants inherited from Logger
Logger::DEFAULT_MEMORY_BUFFER_LINES, Logger::TIME_FORMAT
Instance Attribute Summary collapse
-
#logs ⇒ Object
Returns the value of attribute logs.
-
#output ⇒ Object
Returns the value of attribute output.
Attributes inherited from Logger
Instance Method Summary collapse
- #debug(m, d, f) ⇒ Object
- #error(m, d, f) ⇒ Object
- #fatal(m, d, f) ⇒ Object
- #info(m, d, f) ⇒ Object
-
#initialize ⇒ DummyLogger
constructor
A new instance of DummyLogger.
- #log(level, message, data, from) ⇒ Object
- #trace(m, d, f) ⇒ Object
- #warn(m, d, f) ⇒ Object
Methods inherited from Logger
#format, #format_data, #format_location, #push
Constructor Details
#initialize ⇒ DummyLogger
Returns a new instance of DummyLogger.
247 248 249 250 |
# File 'lib/norikra/logger.rb', line 247 def initialize @logs = { :TRACE => [], :DEBUG => [], :INFO => [], :WARN => [], :ERROR => [], :FATAL => [] } @output = [] end |
Instance Attribute Details
#logs ⇒ Object
Returns the value of attribute logs.
246 247 248 |
# File 'lib/norikra/logger.rb', line 246 def logs @logs end |
#output ⇒ Object
Returns the value of attribute output.
246 247 248 |
# File 'lib/norikra/logger.rb', line 246 def output @output end |
Instance Method Details
#debug(m, d, f) ⇒ Object
257 |
# File 'lib/norikra/logger.rb', line 257 def debug(m,d,f); self.log(:DEBUG,m,d,f); end |
#error(m, d, f) ⇒ Object
260 |
# File 'lib/norikra/logger.rb', line 260 def error(m,d,f); self.log(:ERROR,m,d,f); end |
#fatal(m, d, f) ⇒ Object
261 |
# File 'lib/norikra/logger.rb', line 261 def fatal(m,d,f); self.log(:FATAL,m,d,f); end |
#info(m, d, f) ⇒ Object
258 |
# File 'lib/norikra/logger.rb', line 258 def info(m,d,f) ; self.log(:INFO, m,d,f); end |
#log(level, message, data, from) ⇒ Object
251 252 253 254 255 |
# File 'lib/norikra/logger.rb', line 251 def log(level, , data, from) @logs[level].push({:message => , :data => data, :from => from}) formatted = sprintf(FORMAT_SIMULATED, Time.now.strftime(TIME_FORMAT), level.to_s, format(from, , data)) @output.push(formatted) end |
#trace(m, d, f) ⇒ Object
256 |
# File 'lib/norikra/logger.rb', line 256 def trace(m,d,f); self.log(:TRACE,m,d,f); end |
#warn(m, d, f) ⇒ Object
259 |
# File 'lib/norikra/logger.rb', line 259 def warn(m,d,f) ; self.log(:WARN, m,d,f); end |