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.



112
113
114
115
116
# File 'lib/ocak/logger.rb', line 112

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



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

def emit(agent_name, event)
  return unless event

  line = format_event(agent_name, event)
  return unless line

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