Class: RuntimeCommand::Logger
- Inherits:
-
Object
- Object
- RuntimeCommand::Logger
- Defined in:
- lib/runtime_command/logger.rb
Instance Attribute Summary collapse
-
#buffered_log ⇒ Object
readonly
Returns the value of attribute buffered_log.
-
#buffered_stderr ⇒ Object
readonly
Returns the value of attribute buffered_stderr.
-
#buffered_stdout ⇒ Object
readonly
Returns the value of attribute buffered_stdout.
Instance Method Summary collapse
- #flash ⇒ Object
-
#initialize(output = true, colors = nil) ⇒ Logger
constructor
A new instance of Logger.
- #stderr(line) ⇒ Object
- #stdin(line) ⇒ Object
- #stdout(line) ⇒ Object
Constructor Details
#initialize(output = true, colors = nil) ⇒ Logger
Returns a new instance of Logger.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/runtime_command/logger.rb', line 5 def initialize(output = true, colors = nil) @output = output stdin_rgb = [204, 204, 0] stdout_rgb = [64, 64, 64] stderr_rgb = [255, 51, 51] if colors stdin_rgb = colors[:stdin] if colors.has_key?(:stdin) stdout_rgb = colors[:stdout] if colors.has_key?(:stdout) stderr_rgb = colors[:stderr] if colors.has_key?(:stderr) end @stdin_color = HighLine::Style.rgb(*stdin_rgb) @stdout_color = HighLine::Style.rgb(*stdout_rgb) @stderr_color = HighLine::Style.rgb(*stderr_rgb) flash end |
Instance Attribute Details
#buffered_log ⇒ Object (readonly)
Returns the value of attribute buffered_log.
3 4 5 |
# File 'lib/runtime_command/logger.rb', line 3 def buffered_log @buffered_log end |
#buffered_stderr ⇒ Object (readonly)
Returns the value of attribute buffered_stderr.
3 4 5 |
# File 'lib/runtime_command/logger.rb', line 3 def buffered_stderr @buffered_stderr end |
#buffered_stdout ⇒ Object (readonly)
Returns the value of attribute buffered_stdout.
3 4 5 |
# File 'lib/runtime_command/logger.rb', line 3 def buffered_stdout @buffered_stdout end |
Instance Method Details
#flash ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/runtime_command/logger.rb', line 50 def flash @buffered_log = '' @buffered_stdout = '' @buffered_stderr = '' return end |
#stderr(line) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/runtime_command/logger.rb', line 41 def stderr(line) puts HighLine.color(line.chomp, @stderr_color) if @output @buffered_log << line @buffered_stderr << line return end |
#stdin(line) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/runtime_command/logger.rb', line 25 def stdin(line) puts HighLine.color(line, @stdin_color) if @output @buffered_log << line + "\n" return end |
#stdout(line) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/runtime_command/logger.rb', line 32 def stdout(line) puts HighLine.color(line.chomp, @stdout_color) if @output @buffered_log << line @buffered_stdout << line return end |