jordansissel / ruby-cabin

Structured+contextual logging experiments in Ruby
Other
153 stars 22 forks source link

Emit timer logs at specified log level #4

Open gsandie opened 13 years ago

gsandie commented 13 years ago

I like the timer logs, however I'd love to be able to have different ones emitted at different levels. e.g. setup some DEBUG timers that I wouldn't normally want to know about.

This pull request isn't really ready to merge, but I wanted to discuss what I was trying to achieve :)

I've added the current log level into the timer log.

I'm not sure of the best way to proceed. I was thinking of sometime like:

logger.time("some_message", "level") { do_stuff }

And default the "level" to be :info.

But I can't work out how to call into the logger mixin so that I could check if the level matches the level we are logging at.

What do you think?

jordansissel commented 13 years ago

Great idea, though not sure what the API should look like - I'm totally open to any ideas here. In the meantime, I"ll give it a ponder over the weekend.

jordansissel commented 13 years ago

If the log level stuff is generalized, it might be easier to hack in conditional time logging... hmm