Skip to content

Instantly share code, notes, and snippets.

@frsyuki
Created October 18, 2011 07:41
Show Gist options
  • Save frsyuki/1294831 to your computer and use it in GitHub Desktop.
Save frsyuki/1294831 to your computer and use it in GitHub Desktop.
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