Module: Rabbit::Logger::Base

Includes:
GetText
Included in:
GUI, STDERR
Defined in:
lib/rabbit/logger/base.rb

Constant Summary

Constants included from GetText

GetText::DOMAIN

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GetText

included

Instance Attribute Details

#levelObject

Returns the value of attribute level.


47
48
49
# File 'lib/rabbit/logger/base.rb', line 47

def level
  @level
end

#webrick_modeObject

Returns the value of attribute webrick_mode.


47
48
49
# File 'lib/rabbit/logger/base.rb', line 47

def webrick_mode
  @webrick_mode
end

Instance Method Details

#<<(message_or_error) ⇒ Object


86
87
88
# File 'lib/rabbit/logger/base.rb', line 86

def <<(message_or_error)
  info(message_or_error)
end

#debug(message_or_error = nil, &block) ⇒ Object


61
62
63
# File 'lib/rabbit/logger/base.rb', line 61

def debug(message_or_error=nil, &block)
  log(Severity::DEBUG, message_or_error, &block)
end

#debug?Boolean

Returns:

  • (Boolean)

54
# File 'lib/rabbit/logger/base.rb', line 54

def debug?; @level <= Severity::DEBUG; end

#error(message_or_error = nil, &block) ⇒ Object


74
75
76
# File 'lib/rabbit/logger/base.rb', line 74

def error(message_or_error=nil, &block)
  log(Severity::ERROR, message_or_error, &block)
end

#error?Boolean

Returns:

  • (Boolean)

57
# File 'lib/rabbit/logger/base.rb', line 57

def error?; @level <= Severity::ERROR; end

#fatal(message_or_error = nil, &block) ⇒ Object


78
79
80
# File 'lib/rabbit/logger/base.rb', line 78

def fatal(message_or_error=nil, &block)
  log(Severity::FATAL, message_or_error, &block)
end

#fatal?Boolean

Returns:

  • (Boolean)

58
# File 'lib/rabbit/logger/base.rb', line 58

def fatal?; @level <= Severity::FATAL; end

#info(message_or_error = nil, &block) ⇒ Object


65
66
67
# File 'lib/rabbit/logger/base.rb', line 65

def info(message_or_error=nil, &block)
  log(Severity::INFO, message_or_error, &block)
end

#info?Boolean

Returns:

  • (Boolean)

55
# File 'lib/rabbit/logger/base.rb', line 55

def info?; @level <= Severity::INFO; end

#initialize(level = Severity::INFO, prog_name = nil) ⇒ Object


48
49
50
51
52
# File 'lib/rabbit/logger/base.rb', line 48

def initialize(level=Severity::INFO, prog_name=nil)
  @level = level
  @prog_name = prog_name
  @webrick_mode = false
end

#log(severity, message_or_error, prog_name = nil, &block) ⇒ Object Also known as: add


90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/rabbit/logger/base.rb', line 90

def log(severity, message_or_error, prog_name=nil, &block)
  severity ||= Severity::UNKNOWN
  prog_name ||= @prog_name
  if need_log?(severity)
    if message_or_error.nil? and block_given?
      message_or_error = yield
    end
    if message_or_error
      do_log(severity, prog_name, make_message(message_or_error))
    end
  end
end

#unknown(message_or_error = nil, &block) ⇒ Object


82
83
84
# File 'lib/rabbit/logger/base.rb', line 82

def unknown(message_or_error=nil, &block)
  log(Severity::UNKNOWN, message_or_error, &block)
end

#unknown?Boolean

Returns:

  • (Boolean)

59
# File 'lib/rabbit/logger/base.rb', line 59

def unknown?; @level <= Severity::UNKNOWN; end

#warning(message_or_error = nil, &block) ⇒ Object Also known as: warn


69
70
71
# File 'lib/rabbit/logger/base.rb', line 69

def warning(message_or_error=nil, &block)
  log(Severity::WARNING, message_or_error, &block)
end

#warning?Boolean

Returns:

  • (Boolean)

56
# File 'lib/rabbit/logger/base.rb', line 56

def warning?; @level <= Severity::WARNING; end