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 |
# File 'lib/runtime_command/logger.rb', line 10 def initialize(output = true, colors = {}) @output = output @has_color = colors != :none if @has_color @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
65 66 67 68 69 70 71 |
# File 'lib/runtime_command/logger.rb', line 65 def flash @buffered_log = '' @buffered_stdout = '' @buffered_stderr = '' nil end |
#stderr(line) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/runtime_command/logger.rb', line 55 def stderr(line) puts HighLine.color(line.chomp, @stderr_color) if @output && @has_color puts line if @output && !@has_color @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
24 25 26 27 28 29 30 31 |
# File 'lib/runtime_command/logger.rb', line 24 def stdin(line) puts HighLine.color(line, @stdin_color) if @output && @has_color puts line if @output && !@has_color @buffered_log << line + "\n" nil end |
#stdout(line) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/runtime_command/logger.rb', line 39 def stdout(line) puts HighLine.color(line.chomp, @stdout_color) if @output && @has_color puts line if @output && !@has_color @buffered_log << line @buffered_stdout << line nil end |
#stdout? ⇒ Boolean
34 35 36 |
# File 'lib/runtime_command/logger.rb', line 34 def stdout? !@buffered_stdout.empty? end |