Module: Cylons::Logging
- Defined in:
- lib/cylons/logging.rb
Class Method Summary collapse
- .initialize_logger(log_target = $stdout, log_level = ::Logger::INFO) ⇒ Object
- .logger ⇒ Object
- .logger=(new_logger) ⇒ Object
Instance Method Summary collapse
- #log_exception(ex) ⇒ Object
- #log_signature ⇒ Object
- #logger ⇒ Object
- #sign_message(message) ⇒ Object
Class Method Details
.initialize_logger(log_target = $stdout, log_level = ::Logger::INFO) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/cylons/logging.rb', line 5 def self.initialize_logger(log_target=$stdout, log_level=::Logger::INFO) @counter ||= 0 @counter = @counter + 1 @logger = ::Logger.new(log_target) @logger.level = log_level @logger end |
.logger ⇒ Object
13 14 15 |
# File 'lib/cylons/logging.rb', line 13 def self.logger defined?(@logger) ? @logger : initialize_logger end |
.logger=(new_logger) ⇒ Object
17 18 19 |
# File 'lib/cylons/logging.rb', line 17 def self.logger=(new_logger) @logger = new_logger end |
Instance Method Details
#log_exception(ex) ⇒ Object
25 26 27 28 29 |
# File 'lib/cylons/logging.rb', line 25 def log_exception(ex) logger.error { ex. } logger.error { ex.backtrace[0..5].join("\n") } logger.debug { ex.backtrace.join("\n") } end |
#log_signature ⇒ Object
31 32 33 |
# File 'lib/cylons/logging.rb', line 31 def log_signature @_log_signature ||= "[#{self.class == Class ? self.name : self.class.name}]" end |
#logger ⇒ Object
21 22 23 |
# File 'lib/cylons/logging.rb', line 21 def logger ::Cylons::Logging.logger end |
#sign_message(message) ⇒ Object
35 36 37 |
# File 'lib/cylons/logging.rb', line 35 def () "#{log_signature} #{}" end |