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.
- #track(task_name = nil, &blk) ⇒ 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 42 43 |
# 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 @last_stage = Stage.new(self, 'unknown', [], 0) end |
Instance Method Details
#begin_stage(stage_name, total = nil, tags = []) ⇒ Object
45 46 47 |
# File 'lib/bosh/director/event_log.rb', line 45 def begin_stage(stage_name, total = nil, = []) @last_stage = Stage.new(self, stage_name, , total) end |
#log_entry(entry) ⇒ Object
74 75 76 |
# File 'lib/bosh/director/event_log.rb', line 74 def log_entry(entry) @logger.info(Yajl::Encoder.encode(entry)) end |
#log_error(error) ⇒ void
This method returns an undefined value.
Adds an error entry to the event log.
64 65 66 67 68 69 70 71 72 |
# File 'lib/bosh/director/event_log.rb', line 64 def log_error(error) @logger.info(Yajl::Encoder.encode( :time => Time.now.to_i, :error => { :code => error.error_code, :message => error., }, )) end |
#track(task_name = nil, &blk) ⇒ Object
49 50 51 |
# File 'lib/bosh/director/event_log.rb', line 49 def track(task_name = nil, &blk) @last_stage.advance_and_track(task_name, &blk) end |
#warn_deprecated(message) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/bosh/director/event_log.rb', line 53 def warn_deprecated() log_entry( 'time' => Time.now.to_i, 'type' => 'deprecation', 'message' => , ) end |