class Log4r::ScribeOutputter

Attributes

category[R]
host[R]
port[R]

Public Class Methods

new(_name, hash={}) click to toggle source
Calls superclass method Log4r::Outputter.new
# File lib/log4r/outputter/scribeoutputter.rb, line 12
def initialize(_name, hash={})
  super(_name, hash)
  @host = (hash[:host] or hash[:host] or 'localhost')
  @port = (hash[:port] or hash[:port] or '1463')
  @category = (hash[:category] or hash[:category] or 'default')

  @client = Scribe.new("#{@host}:#{@port}", category=@category, add_newlines=false)
end

Private Instance Methods

write(data) click to toggle source
# File lib/log4r/outputter/scribeoutputter.rb, line 23
def write(data)
  begin
    @client.log(data.strip, @category)
  rescue ScribeThrift::Client::TransportException => e
    Logger.log_internal(-2) {
      "Caught TransportException, is the scribe server alive?"
    }
  rescue ThriftClient::NoServersAvailable => e
    Logger.log_internal(-2) {
      "No scribe servers are available!"
    }
  end
end