/** * Function for logging messages and errors. The log will be added in db (it will be not added * if level is DEBUG and the conf variable "debug" is set to false), a log is shown on screen * if conf variable "display_log" is set to true. If the level is LOG_LEVEL_FATAL_ERROR the * application will die immediately. * * @param string $cathegory The cathegory of the error * @param int $level One of the predefined level constants * - LOG_LEVEL_FATAL_ERROR * - LOG_LEVEL_ERROR * - LOG_LEVEL_WARNING * - LOG_LEVEL_NOTICE * - LOG_LEVEL_DEBUG * @param string $message Description og the log entry * @param string $filename The filename where the log was generated (can use the __FILE__ keyword) * @param string $line The line where the log was generated (can use the __LINE__ keyword) * @static */ function log($cathegory, $level, $message, $filename = '', $line = 0) { //prevent deadlock global $g_in_log; if (isset($g_in_log)) { exit("Fatal Error, contact webmaster (Error: Log Recursion)"); } $g_in_log = true; $log_entry = new xLogEntry(0, $cathegory, $level, $message, $filename, $line, isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', $_SERVER['REQUEST_URI'], time(), $_SERVER['REMOTE_ADDR'], NULL); if ($level != LOG_LEVEL_DEBUG || xConf::get('debug', false)) { $log_entry->m_stacktrace = xStackTrace::getCurrent(2); if (xConf::get('display_log', false)) { $log_entry->insertToScreen(); } $log_entry->insert(); } if ($level == LOG_LEVEL_FATAL_ERROR) { exit("Fatal Error, please contact the webmaster"); } $g_in_log = NULL; }