/** * logs a given text to all enabled logger-facilities * * @param int $action * @param int $type * @param string $text */ public function logAction($action = USR_ACTION, $type = LOG_NOTICE, $text = null) { if (self::$logtypes == null) { return; } if (self::$crondebug_flag || $action == CRON_ACTION && $type <= LOG_WARNING) { echo "[" . getLogLevelDesc($type) . "] " . $text . PHP_EOL; } if (Settings::Get('logger.log_cron') == '0' && $action == CRON_ACTION && $type > LOG_WARNING) { return; } foreach (self::$logtypes as $logger) { switch ($logger) { case 'syslog': $_log = SysLogger::getInstanceOf($this->userinfo); break; case 'file': try { $_log = FileLogger::getInstanceOf($this->userinfo); } catch (Exception $e) { if ($action != CRON_ACTION) { standard_error('logerror', $e->getMessage()); } else { echo "Log-Error: " . $e->getMessage(); } } break; case 'mysql': $_log = MysqlLogger::getInstanceOf($this->userinfo); break; default: $_log = null; break; } if ($_log != null) { try { $_log->logAction($action, $type, $text); } catch (Exception $e) { if ($action != CRON_ACTION) { standard_error('logerror', $e->getMessage()); } else { echo "Log-Error: " . $e->getMessage(); } } } } }
break; case LOGIN_ACTION: $_action = $lng['logger']['login']; break; case LOG_ERROR: $_action = $lng['logger']['intern']; break; default: $_action = $lng['logger']['unknown']; break; } $row['action'] = $_action; eval("\$log.=\"" . getTemplate('logger/logger_action') . "\";"); } $log_count++; $row['type'] = getLogLevelDesc($row['type']); eval("\$log.=\"" . getTemplate('logger/logger_log') . "\";"); $count++; $_action = $action; } $i++; } $i++; } eval("echo \"" . getTemplate('logger/logger') . "\";"); } elseif ($action == 'truncate') { if (isset($_POST['send']) && $_POST['send'] == 'send') { $truncatedate = time() - 60 * 10; $trunc_stmt = Database::prepare("\n\t\t\t\tDELETE FROM `" . TABLE_PANEL_LOG . "` WHERE `date` < :trunc"); Database::pexecute($trunc_stmt, array('trunc' => $truncatedate)); $log->logAction(ADM_ACTION, LOG_WARNING, 'truncated the system-log (mysql)');
/** * logs a given text to all enabled logger-facilities * * @param int $action * @param int $type * @param string $text */ public function logAction($action = USR_ACTION, $type = LOG_NOTICE, $text = null) { global $lng; if (parent::isEnabled()) { if (parent::getSeverity() <= 1 && $type == LOG_NOTICE) { return; } $_action = 'unknown'; switch ($action) { case USR_ACTION: $_action = $lng['admin']['customer']; break; case RES_ACTION: $_action = $lng['logger']['reseller']; break; case ADM_ACTION: $_action = $lng['logger']['admin']; break; case CRON_ACTION: $_action = $lng['logger']['cron']; break; case LOGIN_ACTION: $_action = $lng['logger']['login']; break; case LOG_ERROR: $_action = $lng['logger']['intern']; break; default: $_action = $lng['logger']['unknown']; break; } if (!isset($this->userinfo['loginname']) || $this->userinfo['loginname'] == '') { $name = 'unknown'; } else { $name = $this->userinfo['loginname']; } openlog("Froxlor", LOG_NDELAY, LOG_USER); if ($text != null && $text != '') { syslog((int) $type, "[" . ucfirst($_action) . " Action " . $name . "] [" . getLogLevelDesc($type) . "] " . $text); } else { syslog((int) $type, "[" . ucfirst($_action) . " Action " . $name . "] [" . getLogLevelDesc($type) . "] No text given!!! Check scripts!"); } closelog(); } }