Class: Caldecott::SessionLogger

Inherits:
Logger
  • Object
show all
Defined in:
lib/caldecott/session_logger.rb

Constant Summary collapse

@@session =
0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(component, *args) ⇒ SessionLogger

Returns a new instance of SessionLogger.



10
11
12
13
14
# File 'lib/caldecott/session_logger.rb', line 10

def initialize(component, *args)
  super(*args)
  @component = component
  @session = @@session += 1
end

Instance Attribute Details

#componentObject (readonly)

Returns the value of attribute component.



7
8
9
# File 'lib/caldecott/session_logger.rb', line 7

def component
  @component
end

#sessionObject (readonly)

Returns the value of attribute session.



7
8
9
# File 'lib/caldecott/session_logger.rb', line 7

def session
  @session
end

Class Method Details

.severity_from_string(str) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/caldecott/session_logger.rb', line 20

def self.severity_from_string(str)
  case str.upcase
  when 'DEBUG'
    Logger::DEBUG
  when 'INFO'
    Logger::INFO
  when 'WARN'
    Logger::WARN
  when 'ERROR'
    Logger::ERROR
  when 'FATAL'
    Logger::FATAL
  when 'UNKNOWN'
    Logger::UNKNOWN
  else
    Logger::ERROR
  end
end

Instance Method Details

#format_message(severity, timestamp, progname, msg) ⇒ Object



16
17
18
# File 'lib/caldecott/session_logger.rb', line 16

def format_message(severity, timestamp, progname, msg)
  "#{@component} [#{@session}] #{msg}\n"
end