Created
January 19, 2011 01:27
-
-
Save tinomen/785512 to your computer and use it in GitHub Desktop.
log client for simple rpc logger using MessagePack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'msgpack' | |
require 'msgpack/rpc' | |
class Logr | |
attr_accessor :client | |
def initialize(ip) | |
@client = MessagePack::RPC::Client.new(ip, 9090) | |
end | |
def log(date, level, msg) | |
client.call(:log, date.to_s, level, msg) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'msgpack' | |
require 'msgpack/rpc' | |
class MyHandler | |
def log(date, level, msg) | |
puts "#{date} - #{level} - #{msg}" | |
end | |
end | |
svr = MessagePack::RPC::Server.new | |
svr.listen('0.0.0.0', 9090, MyHandler.new) | |
puts "ready to party" | |
svr.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment