Class: Log
- Inherits:
-
Object
- Object
- Log
- Defined in:
- lib/tochka/log.rb
Instance Method Summary collapse
- #debug(str) ⇒ Object
- #err(str) ⇒ Object
- #info(str) ⇒ Object
-
#initialize(opts = {}) ⇒ Log
constructor
A new instance of Log.
- #warn(str) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Log
Returns a new instance of Log.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/tochka/log.rb', line 3 def initialize opts={} @debug_mode = opts[:debug_mode] || false @output = opts[:output] || STDOUT case @output when "STDOUT" @output = STDOUT when "STDERR" @output = STDERR end @logger = Logger.new(@output) @logger.datetime_format = "%Y%m%d%H%m%S" @logger.formatter = proc { |severity, datetime, progname, msg| "[#{datetime}] #{progname}\t#{severity}: #{msg}\n" } end |
Instance Method Details
#debug(str) ⇒ Object
33 34 35 |
# File 'lib/tochka/log.rb', line 33 def debug str @logger.debug(str) end |
#err(str) ⇒ Object
25 26 27 |
# File 'lib/tochka/log.rb', line 25 def err str @logger.error(str) end |
#info(str) ⇒ Object
29 30 31 |
# File 'lib/tochka/log.rb', line 29 def info str @logger.info(str) end |
#warn(str) ⇒ Object
21 22 23 |
# File 'lib/tochka/log.rb', line 21 def warn str @logger.err(str) end |