Class: Fyi::Notifier::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/fyi/notifiers/log.rb

Overview

Logs command execution to a file.

The log level depends on the execution result: INFO if the command succeeded, WARN if it failed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Log

Options you can supply: file: full path to a log file. Defaults to fyi.log in the process’s home directory.



15
16
17
18
# File 'lib/fyi/notifiers/log.rb', line 15

def initialize options
  log_file = options['file'] || default_log_file
  @logger = Logger.new log_file
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



10
11
12
# File 'lib/fyi/notifiers/log.rb', line 10

def logger
  @logger
end

Instance Method Details

#notify(command, result, duration, output, error = '', host = '') ⇒ Object



20
21
22
# File 'lib/fyi/notifiers/log.rb', line 20

def notify command, result, duration, output, error = '', host = ''
  logger.log severity(result), message(command, result, duration, output, error, host)
end