fredag den 26. september 2014

Centralized cron and logging

Once too often, I come across modules that implements features, such as specific cron handling and logging.

While this may sometimes be practical, it almost eventually leads to the same problems.

1.) Specific cron handling is inflexible and is implemented in different ways for each module, each with their own bugs and quirks.

2.) Debug logging is always missing when you need it the most. One of the reasons it's usually missing, is because you don't want to inadvertently spam the error log, and you may not have time to implement a debug-log toggle switch. Even if a debug-log toggle switch is implemented, again each module will do it in their own ways, each with their quirks and bugs.


I propose a centralised solution for this.

1.) Use Ultimate Cron for handling cron. This will isolate the cron handling to Ultimate Cron, thus making it a bit easier to debug, since their multiple implementations of cron handling won't exists.

2.) Use Watchdog Filtering for handling debug-log toggling. This way, you can implement debug logging in your module where it makes sense, without having to worry about performance or spamming logs in the production system. The debug-logging can easily be switched on/off, even per module. So when you eventually DO need debug logging in the production system (because, hey, that WILL happen), you don't need to first implement debug logging AND deploy the code.