Hotaru Docs


Error Logging

PHP Error Log

Hotaru will log PHP errors and warnings to the error_log.php file in your cache folder. You can view that log in your browser from Admin -> Maintenance -> Debug. You'll notice you can also delete debug files from that same page. It's a good idea to clear the logs every now and again, especially if they grow large.

Logging for Developers

Hotaru CMS has a few debugging functions that can help you with testing. This tutorial details how to log results from your plugin to a file in the /cache/debug_logs/ directory.

Note: To use this feature, enable Debug mode in Admin -> Settings

1. Open a log file

$h->openLog('log_test', 'a+');

The openLog function takes two parameters: a filename without an extension, and an access mode (list of modes here). Using the 'a+' mode as in this example will create the file if it doesn't exist, open it, and append new data to the end.

2. Write to the file

$h->writeLog('log_test', 'This message will be written to the log file');

Again, include the filename, and put your message in the second parameter. You can repeat this step for as many messages as you like.

3. Close the file


Example 1

This example creates a log file to track admin users:

if ($h->currentUser->role == 'admin') {
        $h->openLog('admin_visits', 'a+');
        $h->writeLog('admin_visits', 'Admin ' . $h->currentUser->name . ' visited ' . $h->pageName);


18 Jan 2010 14:38:43: Moderator Nick visited index 

Example 2

This example logs the execution time of a function. Note that the 'w' mode in openLog rewrites the file every time instead of appending the result to the end of the previous results:

$h->openLog('speed_test', 'w');
    $start = microtime(true);
    // insert big function here
    $end = microtime(true);
    $time = $end - $start;
    $h->writeLog('speed_test', 'This function took ' . round($time, 2) . ' seconds to complete.');


18 Jan 2010 15:03:21: This function took 1.03 seconds to complete.


  • You can have more than one log file open at a time.
  • You can delete these logs from Admin -> Maintenance -> Debug.
  • If you leave the filename and mode parameters empty, i.e. $h->openLog(), Hotaru will use the defaults 'debug' and 'a+'.
Getting StartedDesign and LayoutPlugin DevelopmentAdvanced TopicsFunction ReferenceTroubleshooting