Class: Bosh::Director::EventLog::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/event_log.rb

Overview

Job update (mysql_node): update |——– | (2/4) 50%

Instance Method Summary collapse

Constructor Details

#initialize(io = nil) ⇒ Log

Returns a new instance of Log.



26
27
28
29
# File 'lib/bosh/director/event_log.rb', line 26

def initialize(io = nil)
  @logger = CustomLogger.new(io || StringIO.new)
  @last_stage = Stage.new(self, 'unknown', [], 0)
end

Instance Method Details

#begin_stage(stage_name, total = nil, tags = []) ⇒ Object



31
32
33
# File 'lib/bosh/director/event_log.rb', line 31

def begin_stage(stage_name, total = nil, tags = [])
  @last_stage = Stage.new(self, stage_name, tags, total)
end

#log_entry(entry) ⇒ Object



60
61
62
# File 'lib/bosh/director/event_log.rb', line 60

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.

Parameters:



50
51
52
53
54
55
56
57
58
# File 'lib/bosh/director/event_log.rb', line 50

def log_error(error)
  @logger.info(Yajl::Encoder.encode(
    :time => Time.now.to_i,
    :error => {
      :code => error.error_code,
      :message => error.message,
    },
  ))
end

#track(task_name = nil, &blk) ⇒ Object



35
36
37
# File 'lib/bosh/director/event_log.rb', line 35

def track(task_name = nil, &blk)
  @last_stage.advance_and_track(task_name, &blk)
end

#warn_deprecated(message) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/bosh/director/event_log.rb', line 39

def warn_deprecated(message)
  log_entry(
    'time' => Time.now.to_i,
    'type' => 'deprecation',
    'message' => message,
  )
end