Logs! Logs! My kingdom for some logs!
First, lets take a moment to really ask ourselves what we need from "logging".
- Logs must be fast and not interfere with application execution
- Logs should be filterable by their importance
- Logs must be easy to write
- Logs must be accurately timestamped
- Logs must be persisted on disk
- Logs must be retrievable
- Logs must not adversely affect users (like disk bloat)
- Logs should be visible as they occur (in the console)
Now this list may seem like overkill, after all it's just logging right? But I adamantly believe that not having any one of these items taken care of from the start will only lead to slowed productivity in the development lifecycle of any application. Now, nicely enough, iOS and Mac OS X have built in logging to the console with NSLog that should easily take care of all of our needs, right? First, I want to say I love NSLog, nothing is easier for just getting output right away in an application without any fuss. But sadly, NSLog just doesn't meet the requirements leaving it to us as developers to create our own solutions (which I will share my lightweight, go-to, re-useable logging solution at the end). Well if NSLog is out, let's tackle the requirements one at a time and establish what we need and why we need it.