Class: Norikra::DummyLogger

Inherits:
Logger
  • Object
show all
Defined in:
lib/norikra/logger.rb

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

Attributes inherited from Logger

#buffer

Instance Method Summary collapse

Methods inherited from Logger

#format, #format_data, #format_location, #push

Constructor Details

#initializeDummyLogger

Returns a new instance of DummyLogger.



271
272
273
274
# File 'lib/norikra/logger.rb', line 271

def initialize
  @logs = { TRACE: [], DEBUG: [], INFO: [], WARN: [], ERROR: [], FATAL: [] }
  @output = []
end

Instance Attribute Details

#logsObject

Returns the value of attribute logs.



270
271
272
# File 'lib/norikra/logger.rb', line 270

def logs
  @logs
end

#outputObject

Returns the value of attribute output.



270
271
272
# File 'lib/norikra/logger.rb', line 270

def output
  @output
end

Instance Method Details

#debug(m, d, f) ⇒ Object



282
# File 'lib/norikra/logger.rb', line 282

def debug(m,d,f); self.log(:DEBUG,m,d,f); end

#enabled?(level) ⇒ Boolean

Returns:

  • (Boolean)


280
# File 'lib/norikra/logger.rb', line 280

def enabled?(level); true; end

#error(m, d, f) ⇒ Object



285
# File 'lib/norikra/logger.rb', line 285

def error(m,d,f); self.log(:ERROR,m,d,f); end

#fatal(m, d, f) ⇒ Object



286
# File 'lib/norikra/logger.rb', line 286

def fatal(m,d,f); self.log(:FATAL,m,d,f); end

#info(m, d, f) ⇒ Object



283
# File 'lib/norikra/logger.rb', line 283

def info(m,d,f) ; self.log(:INFO, m,d,f); end

#log(level, message, data, from) ⇒ Object



275
276
277
278
279
# File 'lib/norikra/logger.rb', line 275

def log(level, message, data, from)
  @logs[level].push({message: message, data: data, from: from})
  formatted = sprintf(FORMAT_SIMULATED, Time.now.strftime(TIME_FORMAT), level.to_s, format(from, message, data))
  @output.push(formatted)
end

#trace(m, d, f) ⇒ Object



281
# File 'lib/norikra/logger.rb', line 281

def trace(m,d,f); self.log(:TRACE,m,d,f); end

#warn(m, d, f) ⇒ Object



284
# File 'lib/norikra/logger.rb', line 284

def warn(m,d,f) ; self.log(:WARN, m,d,f); end