Support Forum
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.
I must say we really don't want to curb your enthusiasm! It is great to see someone actually working on a plugin and contributing improvements. So serious answers...
- There is no standard place because we have never needed to create one. As you will have noticed the current log is simply retained in the database (the last 50 records I believe). So you could define them anywhere that is convenient but have you considered actually extending the use of the database table for this? That would certainly be my first choice - a few extra columns as needed.
- if you go down the log file route as opposed to the database then I would agree that a CRON task would be best. If you look at the main PBE plugin file at line 67 you will find the 4 action hooks defined to set this up. The four functions these actions trigger are lower down near the bottom of the file and you should be able to trace them with ease to see how the CRON tasks are set up within WP.
- Again I would say yes if you are going down the text file route and no if using the database. I think that makes sense.
SO now I am really curious to see how this goes!
YELLOW
SWORDFISH
|
1 Guest(s)