Class: NewRelic::Agent::AgentLogger
- Inherits:
-
Object
- Object
- NewRelic::Agent::AgentLogger
show all
- Includes:
- LogOnce
- Defined in:
- lib/new_relic/agent/agent_logger.rb
Constant Summary
Constants included
from LogOnce
LogOnce::NUM_LOG_ONCE_KEYS
Instance Method Summary
collapse
Methods included from LogOnce
#clear_already_logged, #log_once
Constructor Details
#initialize(root = '', override_logger = nil) ⇒ AgentLogger
Returns a new instance of AgentLogger.
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/new_relic/agent/agent_logger.rb', line 17
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!
disable_log_instrumentation!
gather_startup_logs
end
|
Instance Method Details
#debug(*msgs, &blk) ⇒ Object
44
45
46
|
# File 'lib/new_relic/agent/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/new_relic/agent/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/new_relic/agent/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/new_relic/agent/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/new_relic/agent/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/new_relic/agent/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
|
68
69
70
|
# File 'lib/new_relic/agent/agent_logger.rb', line 68
def log_formatter=(formatter)
@log.formatter = formatter
end
|
#warn(*msgs, &blk) ⇒ Object
36
37
38
|
# File 'lib/new_relic/agent/agent_logger.rb', line 36
def warn(*msgs, &blk)
format_and_send(:warn, msgs, &blk)
end
|