Class: Redis::Logger
- Inherits:
-
Logger
- Object
- Logger
- Redis::Logger
show all
- Includes:
- Severity
- Defined in:
- lib/redis/logger.rb
Defined Under Namespace
Modules: Severity
Constant Summary
Constants included
from Severity
Severity::DEBUG, Severity::ERROR, Severity::FATAL, Severity::INFO, Severity::NOTICE, Severity::SEV_LABEL, Severity::UNKNOWN, Severity::WARN
Instance Method Summary
collapse
Constructor Details
#initialize(logdev, *args) ⇒ Logger
Redis levels are: DEBUG < INFO < NOTICE < WARNING This logger inserts support for NOTICE
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/redis/logger.rb', line 9
def initialize(logdev, *args)
super
@raw_logdev = logdev
@default_formatter = proc { |severity, datetime, progname, msg|
mark = case severity
when 'DEBUG' then '.'
when 'INFO' then '-'
when 'NOTE' then '*'
when 'WARN' then '#'
else '!'
end
"[#{Process.pid}] #{datetime.strftime '%d %b %H:%H:%S'} #{mark} #{msg}\n"
}
end
|
Instance Method Details
#error(progname = nil, &block) ⇒ Object
47
48
49
|
# File 'lib/redis/logger.rb', line 47
def error(progname = nil, &block)
add(ERROR, nil, progname, &block)
end
|
#error? ⇒ Boolean
59
|
# File 'lib/redis/logger.rb', line 59
def error?; @level <= ERROR; end
|
#fatal(progname = nil, &block) ⇒ Object
50
51
52
|
# File 'lib/redis/logger.rb', line 50
def fatal(progname = nil, &block)
add(FATAL, nil, progname, &block)
end
|
#fatal? ⇒ Boolean
60
|
# File 'lib/redis/logger.rb', line 60
def fatal?; @level <= FATAL; end
|
#flush ⇒ Object
24
25
26
|
# File 'lib/redis/logger.rb', line 24
def flush
@raw_logdev.flush if @raw_logdev.respond_to? :flush
end
|
#notice(progname = nil, &block) ⇒ Object
41
42
43
|
# File 'lib/redis/logger.rb', line 41
def notice(progname = nil, &block)
add(NOTICE, nil, progname, &block)
end
|
#notice? ⇒ Boolean
57
|
# File 'lib/redis/logger.rb', line 57
def notice?; @level <= NOTICE; end
|
#unknown(progname = nil, &block) ⇒ Object
53
54
55
|
# File 'lib/redis/logger.rb', line 53
def unknown(progname = nil, &block)
add(UNKNOWN, nil, progname, &block)
end
|
#warn(progname = nil, &block) ⇒ Object
44
45
46
|
# File 'lib/redis/logger.rb', line 44
def warn(progname = nil, &block)
add(WARN, nil, progname, &block)
end
|
#warn? ⇒ Boolean
58
|
# File 'lib/redis/logger.rb', line 58
def warn?; @level <= WARN; end
|