Class: Log
- Inherits:
-
Object
- Object
- Log
- Defined in:
- lib/log.rb
Overview
Create a Logger that is a singleton provided by the instance method
Class Method Summary collapse
Class Method Details
.create_logger(log_file) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/log.rb', line 8 def self.create_logger(log_file) log_file = STDOUT if log_file == nil logger = Logger.new(log_file) logger.datetime_format = "%Y-%m-%d %H:%M:%S" logger.formatter = proc do |severity, datetime, progname, msg| "#{datetime}: #{msg}\n" end logger end |
.instance(log_file = nil) ⇒ Object
4 5 6 |
# File 'lib/log.rb', line 4 def self.instance(log_file = nil) @@instance ||= create_logger(log_file) end |