Class: DoSnapshot::Log
- Inherits:
-
Object
- Object
- DoSnapshot::Log
- Defined in:
- lib/do_snapshot/log.rb
Overview
Shared logger
Instance Attribute Summary collapse
- #buffer ⇒ Object
- #instance ⇒ Object
-
#quiet ⇒ Object
Returns the value of attribute quiet.
-
#shell ⇒ Object
Returns the value of attribute shell.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(options = {}) ⇒ Log
constructor
A new instance of Log.
- #log(severity, message = nil, progname = nil, &block) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Log
Returns a new instance of Log.
12 13 14 15 16 17 |
# File 'lib/do_snapshot/log.rb', line 12 def initialize( = {}) @verbose = DoSnapshot.config.verbose @quiet = DoSnapshot.config.quiet .each { |key, option| instance_variable_set(:"@#{key}", option) } instance.level = DoSnapshot.config.logger_level if instance end |
Instance Attribute Details
#buffer ⇒ Object
23 24 25 |
# File 'lib/do_snapshot/log.rb', line 23 def buffer @buffer ||= %w() end |
#instance ⇒ Object
19 20 21 |
# File 'lib/do_snapshot/log.rb', line 19 def instance @instance ||= DoSnapshot.config.logger end |
#quiet ⇒ Object
Returns the value of attribute quiet.
9 10 11 |
# File 'lib/do_snapshot/log.rb', line 9 def quiet @quiet end |
#shell ⇒ Object
Returns the value of attribute shell.
8 9 10 |
# File 'lib/do_snapshot/log.rb', line 8 def shell @shell end |
#verbose ⇒ Object
Returns the value of attribute verbose.
9 10 11 |
# File 'lib/do_snapshot/log.rb', line 9 def verbose @verbose end |
Instance Method Details
#close ⇒ Object
31 32 33 |
# File 'lib/do_snapshot/log.rb', line 31 def close instance.close if instance end |
#log(severity, message = nil, progname = nil, &block) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/do_snapshot/log.rb', line 39 def log(severity, = nil, progname = nil, &block) buffer << instance.add(severity, , progname, &block) if instance say , color(severity) unless print?(severity) end |