Class: TingYun::Logger::AgentLogger
Constant Summary
Constants included
from LogOnce
LogOnce::NUM_LOG_ONCE_KEYS
Instance Attribute Summary collapse
Instance Method Summary
collapse
check_log_file, create_log, create_log_to_file, create_new_logfile, create_null_logger, find_or_create_file_path
Methods included from LogOnce
#clear_already_logged, #log_once
Constructor Details
#initialize(root = "", override_logger = nil) ⇒ AgentLogger
Returns a new instance of AgentLogger.
18
19
20
21
22
23
24
25
26
|
# File 'lib/ting_yun/logger/agent_logger.rb', line 18
def initialize(root = "", override_logger=nil)
@already_logged_lock = Mutex.new
clear_already_logged
create_log(root, override_logger)
set_log_level
set_log_format
gather_startup_logs
end
|
Instance Attribute Details
#file_path ⇒ Object
Returns the value of attribute file_path.
17
18
19
|
# File 'lib/ting_yun/logger/agent_logger.rb', line 17
def file_path
@file_path
end
|
Instance Method Details
#debug(*msgs, &blk) ⇒ Object
44
45
46
|
# File 'lib/ting_yun/logger/agent_logger.rb', line 44
def debug(*msgs, &blk)
format_and_send(:debug, msgs, &blk)
end
|
#error(*msgs, &blk) ⇒ Object
32
33
34
|
# File 'lib/ting_yun/logger/agent_logger.rb', line 32
def error(*msgs, &blk)
format_and_send(:error, msgs, &blk)
end
|
#fatal(*msgs, &blk) ⇒ Object
28
29
30
|
# File 'lib/ting_yun/logger/agent_logger.rb', line 28
def fatal(*msgs, &blk)
format_and_send(:fatal, msgs, &blk)
end
|
#info(*msgs, &blk) ⇒ Object
40
41
42
|
# File 'lib/ting_yun/logger/agent_logger.rb', line 40
def info(*msgs, &blk)
format_and_send(:info, msgs, &blk)
end
|
#is_startup_logger? ⇒ Boolean
48
49
50
|
# File 'lib/ting_yun/logger/agent_logger.rb', line 48
def is_startup_logger?
@log.is_a?(NullLogger)
end
|
#log_exception(level, e, backtrace_level = level) ⇒ Object
Use this when you want to log an exception with explicit control over the log level that the backtrace is logged at. If you just want the default behavior of backtraces logged at debug, use one of the methods above and pass an Exception as one of the args.
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/ting_yun/logger/agent_logger.rb', line 56
def log_exception(level, e, backtrace_level=level)
@log.send(level, "%p: %s" % [e.class, e.message])
@log.send(backtrace_level) do
backtrace = backtrace_from_exception(e)
if backtrace
"Debugging backtrace:\n" + backtrace.join("\n ")
else
"No backtrace available."
end
end
end
|
#warn(*msgs, &blk) ⇒ Object
36
37
38
|
# File 'lib/ting_yun/logger/agent_logger.rb', line 36
def warn(*msgs, &blk)
format_and_send(:warn, msgs, &blk)
end
|