Class: Filbunke::Logger

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

Instance Method Summary collapse

Constructor Details

#initialize(log_file_name, local) ⇒ Logger

Returns a new instance of Logger.



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

def initialize(log_file_name, local)
  @local = local
  @log_file = ::File.open(log_file_name, "a") unless local
end

Instance Method Details

#log(msg) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/filbunke/logger.rb', line 9

def log(msg)
  if @local then
    puts "#{Time.now}: #{msg}"
  else
    @log_file.write("#{Time.now}: #{msg}\n")
    @log_file.flush
  end
end