On Logging
Recently I archived an old github repo log project. In the readme I referenced this great article on logging. In the article Dave Cheney makes a great case that log levels should be limited to just Debug and Info. Some of the log levels out there can get out of hand, so it’s nice to see an argument for a simplified approach. Since reading the article I have been zealous about removing Warning and Fatal logs from my code. Error logs on the other hand, I have kept using. Generally it’s just too easy and helpful to have that error log entry for monitoring and troubleshooting.
But warning and fatal are easy to drop.
On Warnings:
“Nobody reads warnings, because by definition nothing went wrong”
“if you’re using some kind of leveled logging then why would you set the level at warning ? You’d set the level at info, or error. Setting the level to warning is an admission that you’re probably logging errors at warning level.”
On Fatal:
“It is commonly accepted that libraries should not use panic1, but if calling log.Fatal2 has the same effect, surely this should also be outlawed.”