class Zlogger::Client
Attributes
options[R]
Public Class Methods
new(options={})
click to toggle source
Create a new logger object. This is the client logging object that sends log messages to the remote log collection daemon. The options hash accepts the following options:
:context => An existing ZMQ::Context object. Defaults to creating a new one. :address => The TCP address to connect to. :port => The TCP port to connect to. :name => The name to use as a prefix for log messages, defaults to the process name and pid, eg “rails:1234”
Calls superclass method
# File lib/zlogger/client.rb, line 15 def initialize(options={}) @options = options super(nil) @logdev = LogDevice.new(self) @logdev.run_socket_thread @formatter = proc do |severity, time, progname, msg| if msg.is_a?(Exception) "#{severity}: #{msg.message} (#{msg.class})\n" + (msg.backtrace || []).join("\n") else "#{severity}: #{msg}" end end end
Public Instance Methods
close()
click to toggle source
# File lib/zlogger/client.rb, line 54 def close @logdev.close end
connect_address()
click to toggle source
# File lib/zlogger/client.rb, line 38 def connect_address options[:address] || "127.0.0.1" end
context()
click to toggle source
# File lib/zlogger/client.rb, line 30 def context @context ||= (ZMQ.context || ZMQ::Context.new) end
log_device()
click to toggle source
# File lib/zlogger/client.rb, line 50 def log_device @logdev end
name()
click to toggle source
# File lib/zlogger/client.rb, line 46 def name options[:name] || "#{File.basename($0)}:#{Process.pid}" end
port()
click to toggle source
# File lib/zlogger/client.rb, line 42 def port options[:port] || Zlogger::DEFAULT_PORT end
queue()
click to toggle source
# File lib/zlogger/client.rb, line 34 def queue @queue ||= Queue.new end