Module: GHTorrent::Logging

Constant Summary

Constants included from Settings

Settings::CONFIGKEYS, Settings::DEFAULTS

Instance Method Summary collapse

Methods included from Settings

#config, #merge, #merge_config_values, #override_config, #settings

Methods included from Utils

included, #read_value, #user_type, #write_value

Instance Method Details

#debug(msg) ⇒ Object



22
23
24
# File 'lib/ghtorrent/logging.rb', line 22

def debug(msg)
  log(:debug, msg)
end

#error(msg) ⇒ Object



10
11
12
# File 'lib/ghtorrent/logging.rb', line 10

def error(msg)
  log(:warn, msg)
end

#info(msg) ⇒ Object



18
19
20
# File 'lib/ghtorrent/logging.rb', line 18

def info(msg)
  log(:info, msg)
end

#loggerrObject

Default logger



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ghtorrent/logging.rb', line 27

def loggerr
  @logger ||= proc do
    @logger_uniq ||= config(:logging_uniq)

    logger = if config(:logging_file).casecmp('stdout')
               Logger.new(STDOUT)
             elsif config(:logging_file).casecmp('stderr')
               Logger.new(STDERR)
             else
               Logger.new(config(:logging_file))
             end

    logger.level =
        case config(:logging_level).downcase
          when 'debug' then
            Logger::DEBUG
          when 'info' then
            Logger::INFO
          when 'warn' then
            Logger::WARN
          when 'error' then
            Logger::ERROR
          else
            Logger::INFO
        end

    logger.formatter = proc do |severity, time, progname, msg|
      if progname.nil? or progname.empty?
        progname = @logger_uniq
      end
      "#{severity}, #{time.iso8601}, #{progname} -- #{msg}\n"
    end
    logger
  end.call

  @logger
end

#warn(msg) ⇒ Object



14
15
16
# File 'lib/ghtorrent/logging.rb', line 14

def warn(msg)
  log(:warn, msg)
end