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
|
# File 'lib/logatron/basic_scoped_logger.rb', line 10
def initialize(logger)
@logger = logger
@logs = Hash[Logatron::SEVERITY_MAP.keys.map { |key| [key, []] }]
end
|
Instance Method Details
#critical(msg) ⇒ Object
35
36
37
|
# File 'lib/logatron/basic_scoped_logger.rb', line 35
def critical(msg)
write(format_log(msg: msg, severity: CRITICAL), CRITICAL)
end
|
#debug(msg) ⇒ Object
23
24
25
|
# File 'lib/logatron/basic_scoped_logger.rb', line 23
def debug(msg)
write(format_log(msg: msg, severity: DEBUG), DEBUG)
end
|
#error(msg) ⇒ Object
31
32
33
|
# File 'lib/logatron/basic_scoped_logger.rb', line 31
def error(msg)
write(format_log(msg: msg, severity: ERROR), ERROR)
end
|
#fatal(msg) ⇒ Object
39
40
41
|
# File 'lib/logatron/basic_scoped_logger.rb', line 39
def fatal(msg)
write(format_log(msg: msg, severity: FATAL), FATAL)
end
|
#flush ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/logatron/basic_scoped_logger.rb', line 47
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
15
16
17
|
# File 'lib/logatron/basic_scoped_logger.rb', line 15
def info(msg)
write(format_log(msg: msg, severity: INFO), INFO)
end
|
#invalid_use(msg) ⇒ Object
27
28
29
|
# File 'lib/logatron/basic_scoped_logger.rb', line 27
def invalid_use(msg)
write(format_log(msg: msg, severity: INVALID_USE), INVALID_USE)
end
|
#warn(msg) ⇒ Object
19
20
21
|
# File 'lib/logatron/basic_scoped_logger.rb', line 19
def warn(msg)
write(format_log(msg: msg, severity: WARN), WARN)
end
|
#write(string, severity = INFO) ⇒ Object
43
44
45
|
# File 'lib/logatron/basic_scoped_logger.rb', line 43
def write(string, severity = INFO)
@logs[severity].push string
end
|