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 = {}) ⇒ Object
constructor
RuntimeCommand::Logger.
- #stderr(line) ⇒ Object
- #stderr? ⇒ Boolean
- #stdin(line) ⇒ Object
- #stdout(line) ⇒ Object
- #stdout? ⇒ Boolean
Constructor Details
#initialize(output = true, colors = {}) ⇒ Object
Returns RuntimeCommand::Logger.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/runtime_command/logger.rb', line 10 def initialize(output = true, colors = {}) @output = output if colors == :default_colors @stdin_color = nil @stdout_color = nil @stderr_color = nil else @stdin_color = colors[:stdin] || HighLine::Style.rgb(204, 204, 0) @stdout_color = colors[:stdout] || HighLine::Style.rgb(64, 64, 64) @stderr_color = colors[:stderr] || HighLine::Style.rgb(255, 51, 51) end 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
64 65 66 67 68 69 70 |
# File 'lib/runtime_command/logger.rb', line 64 def flash @buffered_log = '' @buffered_stdout = '' @buffered_stderr = '' nil end |
#stderr(line) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/runtime_command/logger.rb', line 55 def stderr(line) puts HighLine.color(line.chomp, @stderr_color) if @output @buffered_log << line @buffered_stderr << line nil end |
#stderr? ⇒ Boolean
50 51 52 |
# File 'lib/runtime_command/logger.rb', line 50 def stderr? !@buffered_stderr.empty? 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" nil end |
#stdout(line) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/runtime_command/logger.rb', line 40 def stdout(line) puts HighLine.color(line.chomp, @stdout_color) if @output @buffered_log << line @buffered_stdout << line nil end |
#stdout? ⇒ Boolean
35 36 37 |
# File 'lib/runtime_command/logger.rb', line 35 def stdout? !@buffered_stdout.empty? end |