Created
October 18, 2011 07:41
-
-
Save frsyuki/1294831 to your computer and use it in GitHub Desktop.
This file contains hidden or 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' | |
class MessagePackedString < String | |
def to_msgpack(out = '') | |
out << self | |
end | |
end | |
def log(tag, record) | |
r = {} | |
record.each_pair {|k,v| | |
r[k] = v.to_msgpack(MessagePackedString.new) rescue v.to_s | |
} | |
r.to_msgpack | |
end | |
log "test", {"a"=>1, "b"=>2} | |
log "test", {"a"=>1, "b"=>2} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment