Class: Killbill::Plugin::KillbillLogger
- Defined in:
- lib/killbill/killbill_logger.rb
Instance Attribute Summary collapse
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#progname ⇒ Object
Returns the value of attribute progname.
Instance Method Summary collapse
- #add(severity, message = nil, progname = nil, &block) ⇒ Object
- #build_message(message = nil) ⇒ Object
- #close ⇒ Object
- #debug(message = nil, &block) ⇒ Object
- #debug? ⇒ Boolean
- #error(message = nil, &block) ⇒ Object (also: #fatal)
- #flush ⇒ Object
- #info(message = nil, &block) ⇒ Object
- #info? ⇒ Boolean
-
#initialize(delegate) ⇒ KillbillLogger
constructor
A new instance of KillbillLogger.
- #warn(message = nil, &block) ⇒ Object (also: #puts, #write)
- #warn? ⇒ Boolean (also: #error?)
Constructor Details
#initialize(delegate) ⇒ KillbillLogger
Returns a new instance of KillbillLogger.
11 12 13 14 15 |
# File 'lib/killbill/killbill_logger.rb', line 11 def initialize(delegate) @logger = delegate # Match Logger levels @log_level = 1 # Logger::INFO end |
Instance Attribute Details
#log_level ⇒ Object
Returns the value of attribute log_level.
8 9 10 |
# File 'lib/killbill/killbill_logger.rb', line 8 def log_level @log_level end |
#progname ⇒ Object
Returns the value of attribute progname.
9 10 11 |
# File 'lib/killbill/killbill_logger.rb', line 9 def progname @progname end |
Instance Method Details
#add(severity, message = nil, progname = nil, &block) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/killbill/killbill_logger.rb', line 45 def add(severity, = nil, progname = nil, &block) case severity when 0 # Logger::DEBUG debug( || progname, &block) when 1 # Logger::INFO info( || progname, &block) when 2 # Logger::WARN warn( || progname, &block) when 3 # Logger::ERROR error( || progname, &block) when 4 # Logger::FATAL fatal( || progname, &block) when 5 # Logger::UNKNOWN info( || progname, &block) else info( || progname, &block) end end |
#build_message(message = nil) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/killbill/killbill_logger.rb', line 64 def ( = nil) if .nil? if block_given? = yield else = '(nil)' end end = .nil? ? '(nil)' : .to_s @progname ? "[#{@progname}] #{final_message}" : end |
#close ⇒ Object
42 43 |
# File 'lib/killbill/killbill_logger.rb', line 42 def close end |
#debug(message = nil, &block) ⇒ Object
17 18 19 |
# File 'lib/killbill/killbill_logger.rb', line 17 def debug(=nil, &block) @logger.log(4, (, &block)) if debug? end |
#debug? ⇒ Boolean
78 79 80 81 |
# File 'lib/killbill/killbill_logger.rb', line 78 def debug? # Logger::DEBUG 0 >= @log_level end |
#error(message = nil, &block) ⇒ Object Also known as: fatal
29 30 31 |
# File 'lib/killbill/killbill_logger.rb', line 29 def error(=nil, &block) @logger.log(1, (, &block)) if error? end |
#flush ⇒ Object
39 40 |
# File 'lib/killbill/killbill_logger.rb', line 39 def flush end |
#info(message = nil, &block) ⇒ Object
21 22 23 |
# File 'lib/killbill/killbill_logger.rb', line 21 def info(=nil, &block) @logger.log(3, (, &block)) if info? end |
#info? ⇒ Boolean
83 84 85 86 |
# File 'lib/killbill/killbill_logger.rb', line 83 def info? # Logger::INFO 1 >= @log_level end |
#warn(message = nil, &block) ⇒ Object Also known as: puts, write
25 26 27 |
# File 'lib/killbill/killbill_logger.rb', line 25 def warn(=nil, &block) @logger.log(2, (, &block)) if warn? end |
#warn? ⇒ Boolean Also known as: error?
88 89 90 91 |
# File 'lib/killbill/killbill_logger.rb', line 88 def warn? # Logger::WARN 2 >= @log_level end |