Module: Smartkiosk::Common::Logging
- Defined in:
- lib/smartkiosk/common/logging.rb
Class Method Summary collapse
Instance Method Summary collapse
- #destination=(value) ⇒ Object
- #init ⇒ Object
- #logger ⇒ Object
- #logger=(val) ⇒ Object
- #service ⇒ Object
- #service=(service) ⇒ Object
Class Method Details
.format(service, severity, time, progname, msg) ⇒ Object
36 37 38 39 40 |
# File 'lib/smartkiosk/common/logging.rb', line 36 def self.format(service, severity, time, progname, msg) "#{service.ljust(10)} -- #{severity[0]}, " << "[#{time.utc.strftime '%Y-%m-%dT%H:%M:%S.%6N'} ##{::Process.pid}] " << "#{severity.rjust(5)} -- : #{msg}\n" end |
Instance Method Details
#destination=(value) ⇒ Object
7 8 9 |
# File 'lib/smartkiosk/common/logging.rb', line 7 def destination=(value) @destination = value end |
#init ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/smartkiosk/common/logging.rb', line 27 def init log = Logger.new(@destination || STDOUT) log.level = Logger::DEBUG log.formatter = proc do |severity, time, progname, msg| Smartkiosk::Common::Logging.format @service, severity, time, progname, msg end log end |
#logger ⇒ Object
23 24 25 |
# File 'lib/smartkiosk/common/logging.rb', line 23 def logger @logger ||= init end |
#logger=(val) ⇒ Object
19 20 21 |
# File 'lib/smartkiosk/common/logging.rb', line 19 def logger=(val) @logger = (val ? val : Logger.new('/dev/null')) end |
#service ⇒ Object
15 16 17 |
# File 'lib/smartkiosk/common/logging.rb', line 15 def service @service end |
#service=(service) ⇒ Object
11 12 13 |
# File 'lib/smartkiosk/common/logging.rb', line 11 def service=(service) @service = service end |