10 ms·
Rails does need a better logger by default, and your idea is really good but I am just not prepared to push this much configuration into my apps. We're talking
by tilsammans 13y ago
Rails does need a better logger by default, and your idea is really good but I am just not prepared to push this much configuration into my apps. We're talking about a yml config file, 14-odd lines in application.rb and an additional 67-line logger initializer.
Given the choice between crappy, non-automatable but still searchable default logs with zero configuration, or this operationally superior solution that requires over 100 lines of code/config I will take the former any time. Also, no way I am introducing a global log check time variable. Is it just me that finds this way too messy? I'd rather push for a Heroku/Scrolls-style logger by default in Rails.
- aaronblohowiak 13y agoEspecially because `Time.now - SOME_TIME` is actually a relatively expensive operation. IIRC, it is faster to have SOME_TIME converted to an int once and to do Time.now.to_i.. or if your timing needs are less precise (such as in this case) you can get an even bigger speedup using a tiny cext: https://github.com/aaronblohowiak/fasttime https://github.com/aaronblohowiak/fasttime shameless plug) However, I ultimately disagree that the filesystem is where you want to store the log level setting but I understand that this is just an example for the blog post :D
- mmlac 13y agoThis is a great point about the time, thank you for the feedback! About storing logs in the fs: I was thinking about i.e. the database but then how do I solve cases like "this one server acts up, can I get the verbose logs from there but not from my other servers?" How would you store the loglevels?
- mmlac 13y agoI can totally understand your point. This is an excessive example with lots of customization. You can get by with a lot less code if you just want to get a sane default-format or a lot more if you want to really fine-tune your logs. The beauty is that you have the option :)
- mmlac 13y agoAnd then there is the option to push all this code into a gem . One line of code in the Gemfile and you are set. :)