Class: Spritz::Logger
- Inherits:
-
Object
- Object
- Spritz::Logger
- Includes:
- Singleton
- Defined in:
- lib/spritz/logger.rb
Instance Attribute Summary collapse
-
#device ⇒ Object
Returns the value of attribute device.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#device ⇒ Object
Returns the value of attribute device.
9 10 11 |
# File 'lib/spritz/logger.rb', line 9 def device @device end |
Class Method Details
.log(*args) ⇒ Object
19 20 21 |
# File 'lib/spritz/logger.rb', line 19 def self.log(*args) instance.log(*args) end |
.log_action(*args) ⇒ Object
15 16 17 |
# File 'lib/spritz/logger.rb', line 15 def self.log_action(*args) instance.log_action(*args) end |
.log_write(*args, &block) ⇒ Object
11 12 13 |
# File 'lib/spritz/logger.rb', line 11 def self.log_write(*args, &block) instance.log_write(*args, &block) end |
Instance Method Details
#log(line) ⇒ Object
46 47 48 49 50 |
# File 'lib/spritz/logger.rb', line 46 def log(line) if @device @device.write(line) end end |
#log_action(what, *rest) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/spritz/logger.rb', line 32 def log_action(what, *rest) case what when 'Render' color = '33' when 'Overwrite' color = '31' when 'Create' color = '32' else color = '36' end log("\e[#{color};1m%12s\e[0m %s\n" % [what, rest.join(' ')]) end |
#log_write(path) {|path| ... } ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/spritz/logger.rb', line 23 def log_write(path, &block) if File.exist?(path) log_action "Overwrite", path else log_action "Create", path end yield path end |