Sha256: 28482b6d8008b249be0506acc233080c2c811ac4673dd0ad1343b7aec43b3d9b

Contents?: true

Size: 998 Bytes

Versions: 64

Compression:

Stored size: 998 Bytes

Contents

# :include: ../rdoc/outputter
#
# == Other Info
#
# Version:: $Id$
# Author:: Leon Torres <leon@ugcs.caltech.edu>

require "log4r/outputter/outputter"
require 'log4r/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

64 entries across 34 versions & 4 rubygems

Version Path
depengine-0.0.31 etc/isolate/ruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.31 etc/isolate/jruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.30 etc/isolate/ruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.30 etc/isolate/jruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.29 etc/isolate/ruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.29 etc/isolate/jruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.28 etc/isolate/ruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.28 etc/isolate/jruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.27 etc/isolate/jruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.27 etc/isolate/ruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.26 etc/isolate/jruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.26 etc/isolate/ruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.25 etc/isolate/ruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.25 etc/isolate/jruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.24 etc/isolate/jruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.24 etc/isolate/ruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.23 etc/isolate/jruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.23 etc/isolate/ruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.22 etc/isolate/ruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb
depengine-0.0.22 etc/isolate/jruby-1.8/gems/log4r-1.1.8/lib/log4r/outputter/udpoutputter.rb