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.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/runtime_command/logger.rb', line 7 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.
5 6 7 |
# File 'lib/runtime_command/logger.rb', line 5 def buffered_log @buffered_log end |
#buffered_stderr ⇒ Object (readonly)
Returns the value of attribute buffered_stderr.
5 6 7 |
# File 'lib/runtime_command/logger.rb', line 5 def buffered_stderr @buffered_stderr end |
#buffered_stdout ⇒ Object (readonly)
Returns the value of attribute buffered_stdout.
5 6 7 |
# File 'lib/runtime_command/logger.rb', line 5 def buffered_stdout @buffered_stdout end |
Instance Method Details
#flash ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/runtime_command/logger.rb', line 52 def flash @buffered_log = '' @buffered_stdout = '' @buffered_stderr = '' return end |
#stderr(line) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/runtime_command/logger.rb', line 43 def stderr(line) puts HighLine.color(line.chomp, @stderr_color) if @output @buffered_log << line @buffered_stderr << line return end |
#stdin(line) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/runtime_command/logger.rb', line 27 def stdin(line) puts HighLine.color(line, @stdin_color) if @output @buffered_log << line + "\n" return end |
#stdout(line) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/runtime_command/logger.rb', line 34 def stdout(line) puts HighLine.color(line.chomp, @stdout_color) if @output @buffered_log << line @buffered_stdout << line return end |