Module: Powcloud::Insurance::Logger

Included in:
Agent, AgentContainer, Comm::AmqpBroadcastChannel
Defined in:
lib/powcloud/insurance/logger.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



8
9
10
# File 'lib/powcloud/insurance/logger.rb', line 8

def logger
  @logger
end

Class Method Details

.outputtersObject



14
15
16
# File 'lib/powcloud/insurance/logger.rb', line 14

def outputters
  @@outputters ||= []
end

.outputters=(ar) ⇒ Object



10
11
12
# File 'lib/powcloud/insurance/logger.rb', line 10

def outputters=(ar)
  @@outputters = ar
end

Instance Method Details

#init_child_logger(logger, name) ⇒ Object



27
28
29
30
# File 'lib/powcloud/insurance/logger.rb', line 27

def init_child_logger(logger, name)
  @logger = Log4r::Logger.new "#{logger.fullname}::#{name}"
  @logger.level = logger.level
end

#init_logger(level = Log4r::WARN, name = File.basename($0)) ⇒ Object

Initializes logger instance.



20
21
22
23
24
25
# File 'lib/powcloud/insurance/logger.rb', line 20

def init_logger(level = Log4r::WARN, name = File.basename($0))
  @logger = Log4r::Logger.new name
  @logger.level = level

  @logger.outputters = Powcloud::Insurance::Logger.outputters
end

#log_exception(ex) ⇒ Object



32
33
34
35
36
37
# File 'lib/powcloud/insurance/logger.rb', line 32

def log_exception(ex)
  if logger
    logger.error ex.to_s + (ex.backtrace.length > 0 ? ' ' + ex.backtrace.first : '')
    logger.error ex.backtrace.join("\n")
  end
end