Class: Flickrage::Log
- Inherits:
-
Object
- Object
- Flickrage::Log
- Defined in:
- lib/flickrage/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
- #add_padding ⇒ Object
- #ask(statement, color: :green, path: false) ⇒ Object
- #close ⇒ Object
-
#initialize(options = {}) ⇒ Log
constructor
A new instance of Log.
- #log(severity, message = nil, progname = nil, &block) ⇒ Object
- #print_table(*args) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Log
Returns a new instance of Log.
12 13 14 15 16 17 |
# File 'lib/flickrage/log.rb', line 12 def initialize( = {}) @verbose = Flickrage.config.verbose @quiet = Flickrage.config.quiet .each { |key, option| instance_variable_set(:"@#{key}", option) } instance.level = Flickrage.config.logger_level if instance end |
Instance Attribute Details
#buffer ⇒ Object
23 24 25 |
# File 'lib/flickrage/log.rb', line 23 def buffer @buffer ||= %w() end |
#instance ⇒ Object
19 20 21 |
# File 'lib/flickrage/log.rb', line 19 def instance @instance ||= Flickrage.config.logger end |
#quiet ⇒ Object
Returns the value of attribute quiet.
9 10 11 |
# File 'lib/flickrage/log.rb', line 9 def quiet @quiet end |
#shell ⇒ Object
Returns the value of attribute shell.
8 9 10 |
# File 'lib/flickrage/log.rb', line 8 def shell @shell end |
#verbose ⇒ Object
Returns the value of attribute verbose.
9 10 11 |
# File 'lib/flickrage/log.rb', line 9 def verbose @verbose end |
Instance Method Details
#add_padding ⇒ Object
54 55 56 |
# File 'lib/flickrage/log.rb', line 54 def add_padding shell.say_status('', '') if shell end |
#ask(statement, color: :green, path: false) ⇒ Object
50 51 52 |
# File 'lib/flickrage/log.rb', line 50 def ask(statement, color: :green, path: false) shell.ask(statement, color, path: path) if shell end |
#close ⇒ Object
31 32 33 |
# File 'lib/flickrage/log.rb', line 31 def close instance.close if instance end |
#log(severity, message = nil, progname = nil, &block) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/flickrage/log.rb', line 58 def log(severity, = nil, progname = nil, &block) buffer << instance.add(severity, , progname, &block) if instance.respond_to?(:add) say(, color(severity)) unless print?(severity) end |
#print_table(*args) ⇒ Object
45 46 47 48 |
# File 'lib/flickrage/log.rb', line 45 def print_table(*args) args[0]&.each { |row| instance.info(row) } if instance shell.print_table(*args) if shell end |