Documentation

Logs

The Logger class is a utility for writing log messages to different types of log drivers. It supports logging to a database or a file, depending on the specified log driver.
The class checks if logging is enabled via configuration settings and handles exceptions by falling back to file logging if database logging fails.

Levels

Is composed by several levels:

  • Log_Level::ERROR
  • Log_Level::WARNING
  • Log_Level::FAILURE
  • Log_Level::INFORMATION
  • Log_Level::SUCCESS
  • Log_Level::CRONJOB

Types

There are two types of log types:

  • Log_Driver:FILE
  • Log_Driver:DATABASE

Usage Example

//Logger::write($message, $level, $type)
Logger::write("Write example Error text in file", Log_Level::ERROR, Log_Driver::FILE);
Logger::write("Write example Info text in database", Log_Level::INFORMATION, Log_Driver::DATABASE);

List

You can also use Log_Database_List class to view list of your log.

$logList = new Log_Database_List();
$logList->loadAll("id", "desc");
print_r($logList->items);

Methods

  • public static function write($message = "", $level = Log_Level::INFORMATION, $type = Log_Driver::DATABASE)
    Write a log message to the specified log driver.
    • $message: The log message to write (default is an empty string).
    • $level: The level of the log message (default is Log_Level::INFORMATION).
    • $type: The type of log driver to use (default is Log_Driver::DATABASE).
    • This method returns void: No return value.