Class: Ocak::WatchFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/ocak/logger.rb

Overview

Colorized real-time terminal output for –watch mode.

Instance Method Summary collapse

Constructor Details

#initialize(io = $stderr) ⇒ WatchFormatter

Returns a new instance of WatchFormatter.



120
121
122
123
124
# File 'lib/ocak/logger.rb', line 120

def initialize(io = $stderr)
  @io = io
  @tty = io.respond_to?(:tty?) && io.tty?
  @mutex = Mutex.new
end

Instance Method Details

#emit(agent_name, event) ⇒ Object



126
127
128
129
130
131
132
133
# File 'lib/ocak/logger.rb', line 126

def emit(agent_name, event)
  return unless event

  line = format_event(agent_name, event)
  return unless line

  @mutex.synchronize { @io.puts line }
end