Sha256: 1f1220951fced9855ca550bffe9f7a41e5bc1f9b7d4b6a55f2bbf67639f68892
Contents?: true
Size: 1010 Bytes
Versions: 2
Compression:
Stored size: 1010 Bytes
Contents
# :include: ../rdoc/outputter # # == Other Info # # Version:: $Id$ # Author:: Leon Torres <leon@ugcs.caltech.edu> require "log4r-color/outputter/outputter" require 'log4r-color/staticlogger' require "socket" module Log4r class UDPOutputter < Outputter attr_reader :host, :port attr_accessor :udpsock def initialize(_name, hash={}) super(_name, hash) @host = hash[:hostname] @port = hash[:port] begin Logger.log_internal { "UDPOutputter will send to #{@host}:#{@port}" } @udpsock = UDPSocket.new @udpsock.connect( @host, @port ) rescue Exception => e Logger.log_internal(ERROR) { "UDPOutputter failed to create UDP socket: #{e}" } Logger.log_internal {e} self.level = OFF raise e end end ####### private ####### def write(data) @udpsock.send(data, 0) rescue Exception => e Logger.log_internal(ERROR) { "UDPOutputter failed to send data to #{@host}:#{@port}, #{e}" } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
log4r-color-1.2.2 | lib/log4r-color/outputter/udpoutputter.rb |
log4r-color-1.2 | lib/log4r-color/outputter/udpoutputter.rb |