class RTALogger::LogTopicWrapper
Attributes
context_id[RW]
level[R]
Logging severity threshold (e.g. Logger::INFO
).
progname[RW]
Public Class Methods
new(context_id, topic, level = 0)
click to toggle source
# File lib/log_topic_wrapper.rb, line 3 def initialize(context_id, topic, level = 0) @context_id = context_id @topic = topic level = level - 1 level = 0 if level.negative? level = 5 if level > 5 self.level = level end
Public Instance Methods
add(severity, message = nil, progname = nil) { || ... }
click to toggle source
# File lib/log_topic_wrapper.rb, line 93 def add(severity, message = nil, progname = nil) severity ||= UNKNOWN if progname.nil? progname = @progname end if message.nil? if block_given? message = yield else message = progname progname = @progname end end rta_logger_topic_log(severity, message) true end
Also aliased as: log
debug(progname = nil, &block)
click to toggle source
# File lib/log_topic_wrapper.rb, line 115 def debug(progname = nil, &block) add(DEBUG, nil, progname, &block) end
debug?()
click to toggle source
Returns true
iff the current severity level allows for the printing of DEBUG
messages.
# File lib/log_topic_wrapper.rb, line 65 def debug?; @level <= DEBUG; end
error(progname = nil, &block)
click to toggle source
# File lib/log_topic_wrapper.rb, line 127 def error(progname = nil, &block) add(ERROR, nil, progname, &block) end
error?()
click to toggle source
Returns true
iff the current severity level allows for the printing of ERROR
messages.
# File lib/log_topic_wrapper.rb, line 83 def error?; @level <= ERROR; end
fatal(progname = nil, &block)
click to toggle source
# File lib/log_topic_wrapper.rb, line 131 def fatal(progname = nil, &block) add(FATAL, nil, progname, &block) end
fatal?()
click to toggle source
Returns true
iff the current severity level allows for the printing of FATAL
messages.
# File lib/log_topic_wrapper.rb, line 89 def fatal?; @level <= FATAL; end
info(progname = nil, &block)
click to toggle source
# File lib/log_topic_wrapper.rb, line 119 def info(progname = nil, &block) add(INFO, nil, progname, &block) end
info?()
click to toggle source
Returns true
iff the current severity level allows for the printing of INFO
messages.
# File lib/log_topic_wrapper.rb, line 71 def info?; @level <= INFO; end
level=(severity)
click to toggle source
Set logging severity threshold.
severity
-
The
Severity
of the log message.
# File lib/log_topic_wrapper.rb, line 38 def level=(severity) if severity.is_a?(Integer) severity = 0 if severity.negative? severity = 5 if severity > 5 @level = severity else case severity.to_s.downcase when 'debug' @level = DEBUG when 'info' @level = INFO when 'warn' @level = WARN when 'error' @level = ERROR when 'fatal' @level = FATAL when 'unknown' @level = UNKNOWN else raise ArgumentError, "invalid log level: #{severity}" end end end
unknown(progname = nil, &block)
click to toggle source
# File lib/log_topic_wrapper.rb, line 135 def unknown(progname = nil, &block) add(UNKNOWN, nil, progname, &block) end
warn(progname = nil, &block)
click to toggle source
# File lib/log_topic_wrapper.rb, line 123 def warn(progname = nil, &block) add(WARN, nil, progname, &block) end
warn?()
click to toggle source
Returns true
iff the current severity level allows for the printing of WARN
messages.
# File lib/log_topic_wrapper.rb, line 77 def warn?; @level <= WARN; end
Private Instance Methods
rta_logger_topic_log(severity, message)
click to toggle source
# File lib/log_topic_wrapper.rb, line 141 def rta_logger_topic_log(severity, message) return if @topic.nil? case severity when DEBUG @topic.debug(@context_id, message) when INFO @topic.info(@context_id, message) when WARN @topic.warning(@context_id, message) when ERROR @topic.error(@context_id, message) when FATAL @topic.fatal(@context_id, message) when UNKNOWN @topic.unknown(@context_id, message) end end