Module: Cylons::Logging

Defined in:
lib/cylons/logging.rb

Class Method Summary collapse

Instance Method Summary collapse

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

.loggerObject



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.message }
  logger.error { ex.backtrace[0..5].join("\n") }
  logger.debug { ex.backtrace.join("\n") }
end

#log_signatureObject



31
32
33
# File 'lib/cylons/logging.rb', line 31

def log_signature
  @_log_signature ||= "[#{self.class == Class ? self.name : self.class.name}]"
end

#loggerObject



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 sign_message(message)
  "#{log_signature} #{message}"
end