Class: Bosh::Director::EventLog::Log
- Defined in:
- lib/bosh/director/event_log.rb
Overview
Job update (mysql_node): update |——– | (2/4) 50%
Instance Method Summary collapse
- #begin_stage(stage_name, total = nil, tags = []) ⇒ Object
-
#initialize(io = nil) ⇒ Log
constructor
A new instance of Log.
- #log_entry(entry) ⇒ Object
-
#log_error(error) ⇒ void
Adds an error entry to the event log.
- #warn(message) ⇒ Object
- #warn_deprecated(message) ⇒ Object
Constructor Details
#initialize(io = nil) ⇒ Log
Returns a new instance of Log.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bosh/director/event_log.rb', line 26 def initialize(io = nil) @logger = Logging::Logger.new('EventLog') if io.is_a?(String) @logger.add_appenders(Logging.appenders.file( 'EventFile', filename: io, layout: Logging.layouts.pattern(:pattern => '%m\n') )) else @logger.add_appenders(Logging.appenders.io( 'EventIO', io || StringIO.new, layout: Logging.layouts.pattern(:pattern => '%m\n') )) end end |
Instance Method Details
#begin_stage(stage_name, total = nil, tags = []) ⇒ Object
43 44 45 |
# File 'lib/bosh/director/event_log.rb', line 43 def begin_stage(stage_name, total = nil, = []) Stage.new(self, stage_name, , total) end |
#log_entry(entry) ⇒ Object
76 77 78 |
# File 'lib/bosh/director/event_log.rb', line 76 def log_entry(entry) @logger.info(JSON.generate(entry)) end |
#log_error(error) ⇒ void
This method returns an undefined value.
Adds an error entry to the event log.
66 67 68 69 70 71 72 73 74 |
# File 'lib/bosh/director/event_log.rb', line 66 def log_error(error) @logger.info(JSON.generate( :time => Time.now.to_i, :error => { :code => error.error_code, :message => error., }, )) end |
#warn(message) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/bosh/director/event_log.rb', line 55 def warn() log_entry( 'time' => Time.now.to_i, 'type' => 'warning', 'message' => ) end |
#warn_deprecated(message) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/bosh/director/event_log.rb', line 47 def warn_deprecated() log_entry( 'time' => Time.now.to_i, 'type' => 'deprecation', 'message' => , ) end |