Module: BackchatClient::BackchatLogger::ClassMethods
- Defined in:
- lib/backchat_client/backchat_logger.rb
Overview
This module acts as a wrapper to include the class/module level methods
Instance Method Summary collapse
-
#create_logger(output = nil) ⇒ Object
Creates a new Logger object and defines the level and format.
-
#log_level=(level) ⇒ Object
change logger level.
-
#logger ⇒ Object
logger getter.
-
#logger=(value) ⇒ Object
logger setter.
Instance Method Details
#create_logger(output = nil) ⇒ Object
Creates a new Logger object and defines the level and format
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/backchat_client/backchat_logger.rb', line 48 def create_logger(output = nil) output.nil? and output = STDOUT logger = Logger.new(output) logger.level = Logger::ERROR #logger.formatter = proc { |severity, datetime, progname, msg| # "#{severity} on #{datetime} at #{progname}: #{msg}\n" #} logger.datetime_format = "%Y-%m-%d %H:%M:%S" logger end |
#log_level=(level) ⇒ Object
change logger level
41 42 43 |
# File 'lib/backchat_client/backchat_logger.rb', line 41 def log_level=(level) logger.level = level end |
#logger ⇒ Object
logger getter
35 36 37 |
# File 'lib/backchat_client/backchat_logger.rb', line 35 def logger @@_logger ||= create_logger end |
#logger=(value) ⇒ Object
logger setter
24 25 26 27 28 29 30 31 |
# File 'lib/backchat_client/backchat_logger.rb', line 24 def logger=(value) # _logger must be static var and not class var to be shared between objects/classes if value.is_a?(String) @@_logger = Logger.new(value) else @@_logger = value end end |