class Yal::UDPlog
Public Class Methods
new(address='127.0.0.1', port=1024, topic='udplog', maxcharlength=280, subtopic: '')
click to toggle source
# File lib/yal.rb, line 18 def initialize(address='127.0.0.1', port=1024, topic='udplog', maxcharlength=280, subtopic: '') @u = UDPSocket.new @address, @port, @topic, @subtopic = address, port, topic, subtopic @maxcharlength = maxcharlength end
Public Instance Methods
debug(s)
click to toggle source
# File lib/yal.rb, line 27 def debug(s) log_message s end
error(s)
click to toggle source
# File lib/yal.rb, line 31 def error(s) log_message(s, :error) end
fatal(s)
click to toggle source
# File lib/yal.rb, line 35 def fatal(s) log_message(s, :fatal) end
info(s)
click to toggle source
# File lib/yal.rb, line 39 def info(s) log_message(s, :info) end
Private Instance Methods
log_message(s, label=:debug)
click to toggle source
# File lib/yal.rb, line 45 def log_message(s, label=:debug) charlimit = @maxcharlength fullmsg, topic = s.split(/ *: */,2).reverse msg = fullmsg.length <= charlimit ? fullmsg : \ fullmsg[0..charlimit - 3] + '...' fqm = [@topic, label.to_s, topic || @subtopic]\ .compact.join('/') + ': ' + msg @u.send fqm, 0, @address, @port end