class Bosh::Director::EventLog::Log

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

Public Class Methods

new(io = nil) click to toggle source
# 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

Public Instance Methods

begin_stage(stage_name, total = nil, tags = []) click to toggle source
# File lib/bosh/director/event_log.rb, line 43
def begin_stage(stage_name, total = nil, tags = [])
  Stage.new(self, stage_name, tags, total)
end
log_entry(entry) click to toggle source
# File lib/bosh/director/event_log.rb, line 76
def log_entry(entry)
  @logger.info(JSON.generate(entry))
end
log_error(error) click to toggle source

Adds an error entry to the event log. @param [DirectorError] error Director error @return [void]

# 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.message,
    },
  ))
end
warn(message) click to toggle source
# File lib/bosh/director/event_log.rb, line 55
def warn(message)
  log_entry(
    'time' => Time.now.to_i,
    'type' => 'warning',
    'message' => message
  )
end
warn_deprecated(message) click to toggle source
# File lib/bosh/director/event_log.rb, line 47
def warn_deprecated(message)
  log_entry(
    'time' => Time.now.to_i,
    'type' => 'deprecation',
    'message' => message,
  )
end