Class: OptionalLogger::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/optional_logger/logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ Logger


5
6
7
# File 'lib/optional_logger/logger.rb', line 5

def initialize(logger)
  @logger = logger
end

Instance Method Details

#add(severity, message = nil, progname = nil, &block) ⇒ Object Also known as: log


13
14
15
# File 'lib/optional_logger/logger.rb', line 13

def add(severity, message = nil, progname = nil, &block)
  @logger.add(severity, message, progname, &block) if @logger
end

#debug(progname_or_message = nil, &block) ⇒ Object


26
27
28
# File 'lib/optional_logger/logger.rb', line 26

def debug(progname_or_message = nil, &block)
  add(::Logger::DEBUG, nil, progname_or_message, &block)
end

#debug?Boolean


52
53
54
55
# File 'lib/optional_logger/logger.rb', line 52

def debug?
  return @logger.debug? if @logger
  false
end

#error(progname_or_message = nil, &block) ⇒ Object


30
31
32
# File 'lib/optional_logger/logger.rb', line 30

def error(progname_or_message = nil, &block)
  add(::Logger::ERROR, nil, progname_or_message, &block)
end

#error?Boolean


62
63
64
65
# File 'lib/optional_logger/logger.rb', line 62

def error?
  return @logger.error? if @logger
  false
end

#fatal(progname_or_message = nil, &block) ⇒ Object


34
35
36
# File 'lib/optional_logger/logger.rb', line 34

def fatal(progname_or_message = nil, &block)
  add(::Logger::FATAL, nil, progname_or_message, &block)
end

#fatal?Boolean


57
58
59
60
# File 'lib/optional_logger/logger.rb', line 57

def fatal?
  return @logger.fatal? if @logger
  false
end

#info(progname_or_message = nil, &block) ⇒ Object


18
19
20
# File 'lib/optional_logger/logger.rb', line 18

def info(progname_or_message = nil, &block)
  add(::Logger::INFO, nil, progname_or_message, &block)
end

#info?Boolean


42
43
44
45
# File 'lib/optional_logger/logger.rb', line 42

def info?
  return @logger.info? if @logger
  false
end

#unknown(progname_or_message = nil, &block) ⇒ Object


38
39
40
# File 'lib/optional_logger/logger.rb', line 38

def unknown(progname_or_message = nil, &block)
  add(::Logger::UNKNOWN, nil, progname_or_message, &block)
end

#warn(progname_or_message = nil, &block) ⇒ Object


22
23
24
# File 'lib/optional_logger/logger.rb', line 22

def warn(progname_or_message = nil, &block)
  add(::Logger::WARN, nil, progname_or_message, &block)
end

#warn?Boolean


47
48
49
50
# File 'lib/optional_logger/logger.rb', line 47

def warn?
  return @logger.warn? if @logger
  false
end

#wrapped_loggerObject


9
10
11
# File 'lib/optional_logger/logger.rb', line 9

def wrapped_logger
  @logger
end