Class: Backup::Logger::Console
- Inherits:
-
Object
- Object
- Backup::Logger::Console
- Defined in:
- lib/backup/logger/console.rb
Defined Under Namespace
Classes: Options
Constant Summary collapse
- COLORS =
{ :info => "\e[32m%s\e[0m", # green :warn => "\e[33m%s\e[0m", # yellow :error => "\e[31m%s\e[0m" # red }
Instance Method Summary collapse
-
#initialize(options = nil) ⇒ Console
constructor
A new instance of Console.
- #log(message) ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ Console
Returns a new instance of Console.
38 39 40 |
# File 'lib/backup/logger/console.rb', line 38 def initialize( = nil) $stdout.sync = $stderr.sync = true end |
Instance Method Details
#log(message) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/backup/logger/console.rb', line 42 def log() io = .level == :info ? $stdout : $stderr lines = .formatted_lines lines.map! {|line| COLORS[.level] % line } if io.tty? io.puts lines end |