Module: Logatron
- Defined in:
- lib/logatron/const.rb,
lib/logatron/railtie.rb,
lib/logatron/version.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
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
- VERSION =
'0.1.4'.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= ⇒ Object
11
12
13
|
# File 'lib/logatron/configuration.rb', line 11
def configuration=
@configuration = configuration
end
|
20
21
22
23
|
# File 'lib/logatron/configuration.rb', line 20
def self.configure
configuration
yield(configuration)
end
|
.critical(msg) ⇒ Object
47
48
49
|
# File 'lib/logatron/logatron.rb', line 47
def critical(msg)
logger.critical(msg)
end
|
.debug(msg) ⇒ Object
51
52
53
|
# File 'lib/logatron/logatron.rb', line 51
def debug(msg)
logger.debug(msg)
end
|
.error(msg) ⇒ Object
31
32
33
|
# File 'lib/logatron/logatron.rb', line 31
def error(msg)
logger.error(msg)
end
|
.fatal(msg) ⇒ Object
43
44
45
|
# File 'lib/logatron/logatron.rb', line 43
def fatal(msg)
logger.fatal(msg)
end
|
Deprecated.
Use operation_context for transportation-layer neutral data.
56
57
58
59
60
61
|
# File 'lib/logatron/logatron.rb', line 56
def
{
'X-Ascent-Log-Id' => msg_id,
'X-Ascent-Site' => site
}
end
|
.info(msg) ⇒ Object
39
40
41
|
# File 'lib/logatron/logatron.rb', line 39
def info(msg)
logger.info(msg)
end
|
.level=(level) ⇒ Object
27
28
29
|
# File 'lib/logatron/logatron.rb', line 27
def level=(level)
logger.level = level
end
|
.log(id: msg_id, site: Logatron.site, msg: '-', severity: Logatron::INFO, request: '-', status: '-', source: '-', &block) ⇒ Object
76
77
78
|
# File 'lib/logatron/logatron.rb', line 76
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
22
23
24
25
|
# File 'lib/logatron/logatron.rb', line 22
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
17
18
19
|
# File 'lib/logatron/logatron.rb', line 17
def logger
@log ||= Logatron::BasicLogger.new
end
|
.operation_context ⇒ Object
63
64
65
66
67
68
|
# File 'lib/logatron/logatron.rb', line 63
def operation_context
{
message_id: msg_id,
site: site
}
end
|
.operation_context=(info) ⇒ Object
70
71
72
73
74
|
# File 'lib/logatron/logatron.rb', line 70
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
84
85
86
|
# File 'lib/logatron/logatron.rb', line 84
def site=(site)
Logatron::Contexts.site = site
end
|
.warn(msg) ⇒ Object
35
36
37
|
# File 'lib/logatron/logatron.rb', line 35
def warn(msg)
logger.warn(msg)
end
|