Class: Quorum::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/templates/logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ Logger

Returns a new instance of Logger.



4
5
6
7
# File 'lib/generators/templates/logger.rb', line 4

def initialize(dir)
  @log_directory = dir
  @log_file      = "quorum.log"
end

Instance Method Details

#log(program, message, exit_status = nil, files = nil) ⇒ Object

Write to log file and exit if exit_status is present.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/generators/templates/logger.rb', line 12

def log(program, message, exit_status = nil, files = nil)
  File.open(File.join(@log_directory, @log_file), "a") do |log|
    log.puts ""
    log.puts Time.now.to_s + " " + program
    log.puts message
    log.puts ""
  end

  if exit_status
    remove_files(files) unless files.nil?
    exit exit_status.to_i
  end
end