diff --git a/application/ManiaControl.php b/application/ManiaControl.php index 5543acf3..f06ba682 100644 --- a/application/ManiaControl.php +++ b/application/ManiaControl.php @@ -34,20 +34,14 @@ require_once ManiaControlDir . 'core' . DIRECTORY_SEPARATOR . 'AutoLoader.php'; \ManiaControl\Logger::setup(); /** - * Log and echo the given text - * - * @param string $message - * @param bool $eol + * @deprecated + * @see \ManiaControl\Logger::log() */ function logMessage($message, $eol = true) { - error_log($message); - if ($eol) { - $message = '[' . date('d-M-Y H:i:s e') . '] ' . $message . PHP_EOL; - } - echo $message; + \ManiaControl\Logger::log($message, $eol); } -logMessage('Starting ManiaControl...'); +\ManiaControl\Logger::log('Starting ManiaControl...'); // Check requirements \ManiaControl\Utils\SystemUtil::checkRequirements(); diff --git a/application/core/Logger.php b/application/core/Logger.php index 70686f5d..8ee7042d 100644 --- a/application/core/Logger.php +++ b/application/core/Logger.php @@ -29,4 +29,43 @@ class Logger { $logFileName .= '.log'; ini_set('error_log', $logFileName); } + + /** + * Log and echo the given Error Message + * + * @param string $message + * @param bool $eol + * @param bool $output + */ + public static function logError($message, $eol = true, $output = true) { + $message = '[ERROR] ' . $message; + self::log($message, $eol, $output); + } + + /** + * Log and output the given Message + * + * @param string $message + * @param bool $eol + * @param bool $output + */ + public static function log($message, $eol = true, $output = true) { + error_log($message); + if ($output) { + self::output($message, $eol); + } + } + + /** + * Echo the given Message + * + * @param string $message + * @param bool $eol + */ + public static function output($message, $eol = true) { + if ($eol) { + $message = '[' . date('d-M-Y H:i:s e') . '] ' . $message . PHP_EOL; + } + echo $message; + } }