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.
14 15 16 17 18 19 20 |
# File 'lib/do_snapshot/log.rb', line 14 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 Hashie.logger = self end |
Instance Attribute Details
#buffer ⇒ Object
26 27 28 |
# File 'lib/do_snapshot/log.rb', line 26 def buffer @buffer ||= %w() end |
#instance ⇒ Object
22 23 24 |
# File 'lib/do_snapshot/log.rb', line 22 def instance @instance ||= DoSnapshot.config.logger end |
#quiet ⇒ Object
Returns the value of attribute quiet.
11 12 13 |
# File 'lib/do_snapshot/log.rb', line 11 def quiet @quiet end |
#shell ⇒ Object
Returns the value of attribute shell.
10 11 12 |
# File 'lib/do_snapshot/log.rb', line 10 def shell @shell end |
#verbose ⇒ Object
Returns the value of attribute verbose.
11 12 13 |
# File 'lib/do_snapshot/log.rb', line 11 def verbose @verbose end |
Instance Method Details
#close ⇒ Object
34 35 36 |
# File 'lib/do_snapshot/log.rb', line 34 def close instance.close if instance end |
#log(severity, message = nil, progname = nil, &block) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/do_snapshot/log.rb', line 42 def log(severity, = nil, progname = nil, &block) buffer << instance.add(severity, , progname, &block) if instance say , color(severity) unless print?(severity) end |