Class: Logatron::BasicScopedLogger
- Inherits:
-
Object
- Object
- Logatron::BasicScopedLogger
show all
- Includes:
- Formatting
- Defined in:
- lib/logatron/basic_scoped_logger.rb
Instance Method Summary
collapse
Methods included from Formatting
#format_log, #milliseconds_elapsed
Constructor Details
Returns a new instance of BasicScopedLogger.
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/logatron/basic_scoped_logger.rb', line 10
def initialize(logger)
@logger = logger
@logs = {
DEBUG => [],
INFO => [],
WARN => [],
ERROR => [],
CRITICAL => [],
FATAL => []
}
end
|
Instance Method Details
#critical(msg) ⇒ Object
38
39
40
|
# File 'lib/logatron/basic_scoped_logger.rb', line 38
def critical(msg)
write(format_log(msg: msg, severity: CRITICAL), CRITICAL)
end
|
#debug(msg) ⇒ Object
30
31
32
|
# File 'lib/logatron/basic_scoped_logger.rb', line 30
def debug(msg)
write(format_log(msg: msg, severity: DEBUG), DEBUG)
end
|
#error(msg) ⇒ Object
34
35
36
|
# File 'lib/logatron/basic_scoped_logger.rb', line 34
def error(msg)
write(format_log(msg: msg, severity: ERROR), ERROR)
end
|
#fatal(msg) ⇒ Object
42
43
44
|
# File 'lib/logatron/basic_scoped_logger.rb', line 42
def fatal(msg)
write(format_log(msg: msg, severity: FATAL), FATAL)
end
|
#flush ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/logatron/basic_scoped_logger.rb', line 50
def flush
Logatron.configuration.loggable_levels.each do |key|
@logs[key].each do |item|
@logger.write(item,SEVERITY_MAP[key])
end
end
end
|
#info(msg) ⇒ Object
22
23
24
|
# File 'lib/logatron/basic_scoped_logger.rb', line 22
def info(msg)
write(format_log(msg: msg, severity: INFO), INFO)
end
|
#warn(msg) ⇒ Object
26
27
28
|
# File 'lib/logatron/basic_scoped_logger.rb', line 26
def warn(msg)
write(format_log(msg: msg, severity: WARN), WARN)
end
|
#write(string, severity = INFO) ⇒ Object
46
47
48
|
# File 'lib/logatron/basic_scoped_logger.rb', line 46
def write(string, severity=INFO)
@logs[severity].push string
end
|