As I’m working on different things with the PBE plugin (I’ll be adding MULTIPART/MIXED email support to the MULTIPART/ALTERNATIVE support I’ve already done), I’m finding it invaluable to log what’s going on.
Thus far I’ve been logging into debug.log, but that’s filled with a bunch of noise from the rest of the system.
So I’m thinking I would like to create two new log files:
1. incoming_messages.txt. Here I would log the structure of the incoming messages as well as the contents (this lets me go back and look at the full MIME structure and troubleshoot accordingly).
2. sent_messages.txt. I did this at first to monitor my success at filtering out the multiple instruction tags, but I expect this will be valuable down the road.
My questions are these:
1. Is there a standard place for log files like this to live for a plugin to a plugin? For pure convenience, I would put them in wp-content/sp-resources/forum-plugins/post-by-email/logs. That way as I’m synchronizing code and data between my machine and the server, the PBE code stays together with its logs.
2. I want to auto-rotate the logs so that I keep 30 days each of both logs. My first thought was to do it as part of the normal execution path so that just before a message is logged, the code checks the age of the current log file and kicks off the rolling procedure if it’s more than 24 hours old. But then I thought that *may* be expensive in terms of processing time, if only for the first post of each day (the happy path is just a timestamp check). Maybe a cron daily task is better suited for this? If so, where should that cron job registration happen within the PBE code? Or should that live within SP-base somehwere?
3. Can I/Should I seek to integrate some of these logging options into the PBE UI? Like Logging On/Off, Days To Keep 1-99, etc.
Appreciate the guidance–I want to implement n a way that will let you guys easily integrate anything of value I might add along the way.