Drupal Log To File

Categories

Component ID

220436

Component name

Drupal Log To File

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Downloads

1421

Component created

Component changed

Component body

The Drupal Log To File is built as an alternative to the watchdog interface, aimed at alleviating database load when logging events/actions of the system. With this module, the developer can send logs directly to a flat file in the format:

HH:MM:SS [MODULE_NAME::FUNCTION_NAME][LOG_LEVEL]: Log Message

and can be called from your code-base like:

drupal_log_to_file("MODULE_NAME::FUNCTION_NAME", "LOG_TYPE", "LOG_LEVEL", "MESSAGE");

The module has six built-in log levels (FATAL, ERROR, WARN, INFO, DEBUG, TRACE) and one default log type (DRUPAL_BASE), but is configurable through an administrative page to add as many types as the developer/user wishes. There is also a built in function, log_to_file_arrject() which allows you to input arrays and/or objects, which will be dumped to the log file in human-readable format, similar to:

global $user;
drupal_log_to_file("My Module::my_module_main", "DRUPAL_BASE", "LOG_LEVEL_TRACE", "New user logged into my_module_main: " . log_to_file_arrject($user));

This project is sponsored by: Barscope Interactive Data Systems