Class: Pbin::Logger

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

Constant Summary collapse

INFO_PREFIX =
'[>]'
WARNING_PREFIX =
'[!]'
ERROR_PREFIX =
'[x]'

Instance Method Summary collapse

Constructor Details

#initializeLogger

Returns a new instance of Logger.



9
10
11
12
# File 'lib/pbin/logger.rb', line 9

def initialize
  puts "#{now} Logging to #{LOGFILE}"
  @log = File.open(LOGFILE, 'ab')
end

Instance Method Details

#error(text) ⇒ Object



26
27
28
# File 'lib/pbin/logger.rb', line 26

def error(text)
  "#{now} #{ERROR_PREFIX} #{error}"
end

#info(text) ⇒ Object



18
19
20
# File 'lib/pbin/logger.rb', line 18

def info(text)
  "#{now} #{INFO_PREFIX} #{text}"
end

#nowObject



14
15
16
# File 'lib/pbin/logger.rb', line 14

def now
  "#{Time.now.strftime("[%Y-%m-%d %H:%M:%S]")}"
end

#warning(text) ⇒ Object



22
23
24
# File 'lib/pbin/logger.rb', line 22

def warning(text)
  "#{now} #{WARNING_PREFIX} #{error}"
end