Class: CiLogger::Logger
- Inherits:
-
Object
show all
- Defined in:
- lib/ci_logger/logger.rb
Instance Method Summary
collapse
Constructor Details
#initialize(original) ⇒ Logger
Returns a new instance of Logger.
5
6
7
8
|
# File 'lib/ci_logger/logger.rb', line 5
def initialize(original)
@original = original
Registry.register(self)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing ⇒ Object
66
67
68
|
# File 'lib/ci_logger/logger.rb', line 66
def method_missing(...)
@original.send(...)
end
|
Instance Method Details
#add(severity, message = nil, progname = nil) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/ci_logger/logger.rb', line 21
def add(severity, message = nil, progname = nil)
if progname.nil?
progname = @progname
end
if message.nil?
if block_given?
message = yield
else
message = progname
progname = @progname
end
end
temporary_log << { severity: severity, message: message, progname: progname }
end
|
#clear ⇒ Object
17
18
19
|
# File 'lib/ci_logger/logger.rb', line 17
def clear
temporary_log.clear
end
|
#debug(progname = nil, &block) ⇒ Object
36
37
38
|
# File 'lib/ci_logger/logger.rb', line 36
def debug(progname = nil, &block)
add(::Logger::DEBUG, nil, progname, &block)
end
|
#error(progname = nil, &block) ⇒ Object
48
49
50
|
# File 'lib/ci_logger/logger.rb', line 48
def error(progname = nil, &block)
add(::Logger::ERROR, nil, progname, &block)
end
|
#fatal(progname = nil, &block) ⇒ Object
52
53
54
|
# File 'lib/ci_logger/logger.rb', line 52
def fatal(progname = nil, &block)
add(::Logger::FATAL, nil, progname, &block)
end
|
#info(progname = nil, &block) ⇒ Object
40
41
42
|
# File 'lib/ci_logger/logger.rb', line 40
def info(progname = nil, &block)
add(::Logger::INFO, nil, progname, &block)
end
|
#sync ⇒ Object
10
11
12
13
14
15
|
# File 'lib/ci_logger/logger.rb', line 10
def sync
temporary_log.each do |l|
@original.add(l[:severity], l[:message], l[:progname])
end
temporary_log.clear
end
|
#unknown(progname = nil, &block) ⇒ Object
56
57
58
|
# File 'lib/ci_logger/logger.rb', line 56
def unknown(progname = nil, &block)
add(::Logger::UNKNOWN, nil, progname, &block)
end
|
#warn(progname = nil, &block) ⇒ Object
44
45
46
|
# File 'lib/ci_logger/logger.rb', line 44
def warn(progname = nil, &block)
add(::Logger::WARN, nil, progname, &block)
end
|