Closed filmhubhq closed 10 years ago
Hi,
sorry for the delay. Just got time to look at the request and I came up with something more configurable. I would rather not change the default behaviour as some people might expect hashes to being printed out the way it works right now. However, I've added a machanism to change it as you like:
format = Yell::Formatter.new do |f|
f.modify(Hash) { |m| m.map { |k,v| "#{k}=#{v}" }.join( ", " ) }
end
logger = Yell.new :stdout, format: format
logger.info :hash => "message"
# => 2013-09-25T17:45:46+02:00 [ INFO] 21046 : hash=message
Your solution is awesome and much better than mine ;-). Thanks for your attention to this.
Currently Hashes are formatted in the log message like this:
Many log analyzers prefer key=value pairs though. Here is a humble pull request to change the Hash formatting to this more parseable format. For example,
would result in
If this is a too radical general change - in case you consider this at all helpful - I could imagine a new 'message' formatter variable instead.