Making better use of the Log File

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Post Reply
Posts: 13273
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE

Making better use of the Log File

Post by cmb » Thu Oct 03, 2013 1:06 pm

Hello Community,

recently there was some discussion about CMSimple_XH's log file. That made me think about the log file in general. Traditionally it is only used to log login events, and the function to do so (writelog()) is defined in cmsimple/login.php. While this is useful information, I assume that most users don't deem it necessary to have a look at the log file except in the case they notice some irregularity and confirm if somebody else has logged in as admin. This way the log file leads a miserable existence, particularly as the information in the log file is not absolutely reliable (it is possible to manipulate the log file even without having FTP access to it).

However, I consider having a log file a valuable feature. We should consider to make it even more useful by logging additional information, e.g. when a mail from the mailform could not be sent and when important changes have been made to the website (for example, changing of the password or restoring a content backup). It might even be used by plugins. This is already possible either by using writelog() or by appending to cmsimple/log.txt "manually". However, without a strictly defined format for each log entry, that might easily result in a chaotic log file that is of not much use.

We may consider to define such format, e.g. as CSV with the columns "type" (info, warning, error), "timestamp", "module" ("core" resp. the name of the plugin), "category"/"event name" and "description". To make it easier to adhere to the format, we can introduce a new function XH_writeLog() or something, which expects the appropriate parameters (note, that writelog() accepts an arbitrary string, and that it uses e() to report any error to write to the log file, what may not be suitable for all uses, e.g. when using AJAX).

To offer a better overview, we may consider to display the log file as a table/grid with sortable columns (maybe with pagination, filtering etc.). This might better be postponed to a future version (CMSimple_XH 1.7/2.0). (It could also be offered by a plugin.)

Christoph M. Becker – Plugins for CMSimple_XH

Post Reply