class Yell::Adapters::Io
def close!
-
close!
def close! @stream.close if @stream.respond_to? :close @stream = nil super end
def colorize!; @colors = true; end
@example
Shortcut to enable colors.
def colorize!; @colors = true; end
def inspectables
-
inspectables
def inspectables super.concat [:formatter, :colors, :sync] end
def open!
-
open!
def open! @stream.sync = self.sync if @stream.respond_to? :sync @stream.flush if @stream.respond_to? :flush super end
def setup!( options )
-
setup!( options )
def setup!( options ) @stream = nil self.colors = options.fetch(:colors, false) self.formatter = options.fetch(:format, options[:formatter]) self.sync = options.fetch(:sync, true) super end
def stream
Adapter classes should provide their own implementation
The IO stream
def stream synchronize { open! if @stream.nil?; @stream } end
def write!( event )
-
write!( event )
def write!( event ) message = formatter.call(event) # colorize if applicable if colors and color = TTYColors[event.level] message = color + message + TTYColors[-1] end stream.syswrite(message) super end