Class: Aoandon::Log

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

Instance Method Summary collapse

Constructor Details

#initialize(verbose = false) ⇒ Log

Returns a new instance of Log.



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/aoandon/log.rb', line 3

def initialize(verbose = false)
  @file = if File.exist?('log/aoandon.yml')
    File.open('log/aoandon.yml', 'a')
  else
    File.open('/var/log/aoandon.yml', 'a')
  end

  @verbose = verbose

  puts "Log file: #{File.expand_path(@file.path)}"
end

Instance Method Details

#message(*args) ⇒ Object



15
16
17
18
19
# File 'lib/aoandon/log.rb', line 15

def message(*args)
  puts args.compact.map(&:to_s).join(' | ') if @verbose
  @file.puts "- #{args.compact.map(&:to_s)}"
  @file.flush
end