Class: Pantheios::Services::SimpleConsoleLogService

Inherits:
Object
  • Object
show all
Defined in:
lib/pantheios/services/simple_console_log_service.rb

Overview

A class that fulfils the Pantheios LogService protocol that allows all severities and logs to the console (via $stdout and $stderr)

NOTE: The LogService protocol is implemented by a class that provides the instance methods severity_logged?(severity : Object) : boolean and log(severity : Object, t : Time, prefix : String, msg : String)

Instance Method Summary collapse

Instance Method Details

#infer_stream(sev) ⇒ Object



76
77
78
79
80
81
# File 'lib/pantheios/services/simple_console_log_service.rb', line 76

def infer_stream sev

	sev = ::Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVEL_VALUES[sev] if ::Symbol === sev

	(sev.to_i < 6) ? $stderr : $stdout
end

#log(sev, t, pref, msg) ⇒ Object



69
70
71
72
73
74
# File 'lib/pantheios/services/simple_console_log_service.rb', line 69

def log sev, t, pref, msg

	stm = infer_stream sev

	stm.puts "#{pref}#{msg}"
end

#severity_logged?(severity) ⇒ Boolean



64
65
66
67
# File 'lib/pantheios/services/simple_console_log_service.rb', line 64

def severity_logged? severity

	true
end