Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
coding-topic
Post By Email: Want to add logging
Avatar
chris.crabtree
Member
Free Members
sp_UserOfflineSmall Offline
Mar 4, 2013 - 3:08 pm

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.

 

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Mar 5, 2013 - 3:07 pm

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...

  1. 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.
  2. 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.
  3. 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!

 

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626