Class: App_logger
- Inherits:
-
Object
- Object
- App_logger
- Defined in:
- lib/logger/logger.rb
Class Method Summary collapse
Instance Method Summary collapse
- #debug(message) ⇒ Object
- #error(message) ⇒ Object
- #fatal(message) ⇒ Object
- #info(message) ⇒ Object
-
#initialize(file_path) ⇒ App_logger
constructor
A new instance of App_logger.
- #log(severity, message) ⇒ Object
- #warn(message) ⇒ Object
Constructor Details
#initialize(file_path) ⇒ App_logger
Returns a new instance of App_logger.
6 7 8 9 10 11 12 13 |
# File 'lib/logger/logger.rb', line 6 def initialize(file_path) ensure_log_directory self.logger = Logger.new(file_path) self.logger.formatter = proc do |severity, datetime, progname, msg| "[#{datetime}] #{severity}: #{msg}\n" end setup_log_level end |
Class Method Details
.instance(file_path = nil) ⇒ Object
15 16 17 |
# File 'lib/logger/logger.rb', line 15 def self.instance(file_path = nil) @instance ||= new(file_path) end |
Instance Method Details
#debug(message) ⇒ Object
27 28 29 |
# File 'lib/logger/logger.rb', line 27 def debug() log(:debug, ) end |
#error(message) ⇒ Object
31 32 33 |
# File 'lib/logger/logger.rb', line 31 def error() log(:error, ) end |
#fatal(message) ⇒ Object
39 40 41 |
# File 'lib/logger/logger.rb', line 39 def fatal() log(:fatal, ) end |
#info(message) ⇒ Object
23 24 25 |
# File 'lib/logger/logger.rb', line 23 def info() log(:info, ) end |
#log(severity, message) ⇒ Object
19 20 21 |
# File 'lib/logger/logger.rb', line 19 def log(severity, ) self.logger.send(severity, ) end |
#warn(message) ⇒ Object
35 36 37 |
# File 'lib/logger/logger.rb', line 35 def warn() log(:warn, ) end |