Module: Logatron
- Defined in:
- lib/logatron/const.rb,
lib/logatron/railtie.rb,
lib/logatron/contexts.rb,
lib/logatron/logatron.rb,
lib/logatron/basic_logger.rb,
lib/logatron/configuration.rb,
lib/logatron/basic_formatter.rb,
lib/logatron/error_formatter.rb,
lib/logatron/backtrace_cleaner.rb,
lib/logatron/message_formatting.rb,
lib/logatron/basic_scoped_logger.rb
Defined Under Namespace
Modules: Formatting, SetupLograge
Classes: BacktraceCleaner, BasicFormatter, BasicLogger, BasicScopedLogger, Configuration, Contexts, ErrorFormatter, Middleware, Railtie
Constant Summary
collapse
- MSG_ID =
:msg_id
- SITE =
:site
- DEBUG =
'DEBUG'.freeze
- INVALID_USE =
'INVALID_USE'.freeze
- INFO =
'INFO'.freeze
- WARN =
'WARN'.freeze
- ERROR =
'ERROR'.freeze
- CRITICAL =
'CRITICAL'.freeze
- FATAL =
'FATAL'.freeze
- SEVERITY_MAP =
Maps Constants to the Logger Severity Integers:
DEBUG = 0
INFO = 1
WARN = 2
ERROR = 3
FATAL = 4
UNKNOWN = 5
Note that the Logatron Severities will be put into the logs (severity => INVALID_USE), for filtering purposes
{
Logatron::DEBUG => 0,
Logatron::INFO => 1,
Logatron::INVALID_USE => 1,
Logatron::WARN => 2,
Logatron::ERROR => 3,
Logatron::CRITICAL => 4,
Logatron::FATAL => 5
}.freeze
Class Method Summary
collapse
Class Method Details
.configuration ⇒ Object
15
16
17
|
# File 'lib/logatron/configuration.rb', line 15
def configuration
@configuration ||= Configuration.new
end
|
.configuration=(config) ⇒ Object
11
12
13
|
# File 'lib/logatron/configuration.rb', line 11
def configuration=(config)
@configuration = config
end
|
20
21
22
23
|
# File 'lib/logatron/configuration.rb', line 20
def self.configure
configuration
yield(configuration)
end
|
.critical(msg) ⇒ Object
46
47
48
|
# File 'lib/logatron/logatron.rb', line 46
def critical(msg)
logger.critical(msg)
end
|
.debug(msg) ⇒ Object
50
51
52
|
# File 'lib/logatron/logatron.rb', line 50
def debug(msg)
logger.debug(msg)
end
|
.error(msg) ⇒ Object
30
31
32
|
# File 'lib/logatron/logatron.rb', line 30
def error(msg)
logger.error(msg)
end
|
.fatal(msg) ⇒ Object
42
43
44
|
# File 'lib/logatron/logatron.rb', line 42
def fatal(msg)
logger.fatal(msg)
end
|
Deprecated.
Use operation_context for transportation-layer neutral data.
55
56
57
58
59
60
|
# File 'lib/logatron/logatron.rb', line 55
def
{
'X-Ascent-Log-Id' => msg_id,
'X-Ascent-Site' => site
}
end
|
.info(msg) ⇒ Object
38
39
40
|
# File 'lib/logatron/logatron.rb', line 38
def info(msg)
logger.info(msg)
end
|
.level=(level) ⇒ Object
26
27
28
|
# File 'lib/logatron/logatron.rb', line 26
def level=(level)
logger.level = level
end
|
.log(id: msg_id, site: Logatron.site, msg: '-', severity: Logatron::INFO, request: '-', status: '-', source: '-', &block) ⇒ Object
75
76
77
|
# File 'lib/logatron/logatron.rb', line 75
def log(id: msg_id, site: Logatron.site, msg: '-', severity: Logatron::INFO, request: '-', status: '-', source: '-', &block)
logger.log(id: id, site: site, msg: msg, severity: severity, request: request, status: status, source: source, &block)
end
|
.log_exception(e, severity, additional_info = {}) ⇒ Object
21
22
23
24
|
# File 'lib/logatron/logatron.rb', line 21
def log_exception(e, severity, additional_info = {})
error_report = configuration.error_formatter.format_error_report(e, additional_info)
logger.send(severity.downcase, error_report)
end
|
.logger ⇒ Object
16
17
18
|
# File 'lib/logatron/logatron.rb', line 16
def logger
@log ||= Logatron::BasicLogger.new
end
|
.operation_context ⇒ Object
62
63
64
65
66
67
|
# File 'lib/logatron/logatron.rb', line 62
def operation_context
{
message_id: msg_id,
site: site
}
end
|
.operation_context=(info) ⇒ Object
69
70
71
72
73
|
# File 'lib/logatron/logatron.rb', line 69
def operation_context=(info)
return unless info.is_a? Hash
self.msg_id = info[:message_id] || info['message_id'] || self.msg_id
self.site = info[:site] || info['site'] || self.site
end
|
.site=(site) ⇒ Object
83
84
85
|
# File 'lib/logatron/logatron.rb', line 83
def site=(site)
Logatron::Contexts.site = site
end
|
.warn(msg) ⇒ Object
34
35
36
|
# File 'lib/logatron/logatron.rb', line 34
def warn(msg)
logger.warn(msg)
end
|