Nomád Documentation

This is a PHP function called logger() that logs messages with various levels of severity to a log file.  
Located in the [basedir]/include/misc.php file.

The function takes three parameters:

* $msg: the message to be logged.
* $level: an optional parameter that specifies the level of severity of the message. The default level is LOGGER_NORMAL.
* $priority: an optional parameter that specifies the priority of the message. The default priority is LOG_INFO.  

The function first checks whether the install.log file is writable and the current module is setup. If so, it sets the $debugging flag to true, the $logfile to install.log, and the $loglevel to LOGGER_ALL. Otherwise, it reads the $debugging, $loglevel, and $logfile values from the configuration file.

The function then checks whether logging is enabled and whether the level of severity of the message is lower than or equal to the configured logging level. If logging is not enabled or the message severity is too low, the function simply returns without doing anything.

If logging is enabled, the function constructs the log message string by formatting the message with the current date and time, the priority of the message, a unique log ID, and the file name, line number, and function name where the logging call was made. It then creates an array of log information, including the filename, log level, message, priority, and whether the message was successfully logged, and calls the logger hook to allow plugins to modify the log information or perform additional logging. If the logged key in the $pluginfo array is not set to true by the hook, the function appends the log message to the log file specified in the configuration.  

View the results at https://https://nomad.fedi-verse.hu/admin/logs/

Overall, this function provides a flexible and extensible way to log messages to a file with various levels of severity and priority. The use of a hook also allows plugins to modify or augment the logging behavior