Module: Readorder::Log

Defined in:
lib/readorder/log.rb

Class Method Summary collapse

Class Method Details

.consoleObject



27
28
29
# File 'lib/readorder/log.rb', line 27

def self.console
  Logging.appenders.stderr.level
end

.console=(level) ⇒ Object



31
32
33
# File 'lib/readorder/log.rb', line 31

def self.console=( level )
  Logging.appenders.stderr.level = level
end

.console_layoutObject



50
51
52
53
54
55
# File 'lib/readorder/log.rb', line 50

def self.console_layout
  @console_layout ||= Logging::Layouts::Pattern.new(
    :pattern      => "%d %5l : %m\n",
    :date_pattern => "%H:%M:%S"
  )
end

.init(options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/readorder/log.rb', line 12

def self.init( options = {} )
  appender = Logging.appenders.stderr
  appender.layout = self.console_layout
  if options['log-file'] then
    appender = ::Logging::Appenders::File.new(
      'readorder',
      :filename => options['log-file'],
      :layout   => self.layout
    )
  end
  
  Readorder.logger.add_appenders( appender )
  self.level = options['log-level'] || :info
end

.layoutObject



43
44
45
46
47
48
# File 'lib/readorder/log.rb', line 43

def self.layout
  @layout ||= Logging::Layouts::Pattern.new(
    :pattern      => "[%d] %5l %6p %c : %m\n",
    :date_pattern => "%Y-%m-%d %H:%M:%S"
  )
end

.levelObject



35
36
37
# File 'lib/readorder/log.rb', line 35

def self.level
  ::Logging::Logger[Readorder].level 
end

.level=(l) ⇒ Object



39
40
41
# File 'lib/readorder/log.rb', line 39

def self.level=( l )
  ::Logging::Logger[Readorder].level = l
end