NSLogger
NSLogger copied to clipboard
Add the ability to set maximum buffer file size
Our log files can get quite big so it'd be nice if we could set a maximum size for them. Once the maximum size is reached, it will start popping off the oldest messages in FIFO order. This is handy because usually when a crash occurs, we only care about what happened near the end. If this is too hard to implement, is there any easy way to properly truncate log files?
It's the eternal question of whether you can actually truncate the FRONT of a file and use it as a FIFO queue. The filesystem cannot do it, so I guess the solution for you would be to implement some logic that uses smaller files and prunes older ones to keep the overall (aggregated) log size reasonable.
You'll have to implement this logic in the client code, right where the buffered files are being managed. I don't think it's too hard to do, but you'll have to add a couple management structures to the Logger struct for this.