From 01a6b37c6de5ca67fdd540248077cb3fdd49e17e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Thu, 1 May 2014 20:18:55 +0200 Subject: [PATCH] date in all log messages --- application/ManiaControl.php | 55 ++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/application/ManiaControl.php b/application/ManiaControl.php index 6e9faf14..f6043cee 100644 --- a/application/ManiaControl.php +++ b/application/ManiaControl.php @@ -4,7 +4,7 @@ define('LOG_WRITE_CURRENT_FILE', 'ManiaControl.log'); // Write current log to extra file in base dir define('LOG_NAME_USE_DATE', true); // Use current date as suffix for log file name in logs folder define('LOG_NAME_USE_PID', true); // Use current process id as suffix for log file name in logs folder - + // Define base dir define('ManiaControlDir', __DIR__); @@ -51,16 +51,18 @@ logMessage('Starting ManiaControl ...'); logMessage('Checking for installed MySQLi ... ', false); if (extension_loaded('mysqli')) { logMessage('FOUND!'); -} else { +} +else { logMessage('NOT FOUND!'); logMessage(' -- You don\'t have MySQLi installed, make sure to check: http://www.php.net/manual/en/mysqli.installation.php'); exit(); } logMessage('Checking for installed cURL ... ', false); -if(extension_loaded('curl')) { +if (extension_loaded('curl')) { logMessage('FOUND!'); -} else { +} +else { logMessage('NOT FOUND!'); logMessage('You don\'t have cURL installed, make sure to check: http://www.php.net/manual/en/curl.installation.php'); exit(); @@ -68,11 +70,15 @@ if(extension_loaded('curl')) { /** * Log and echo the given text - * + * * @param string $message */ function logMessage($message, $eol = true) { - if($eol) $message .= PHP_EOL; + $date = date("d.M y H:i:s"); + $message = $date . ' ' . $message; + if ($eol) { + $message .= PHP_EOL; + } if (defined('LOG_CURRENT_FILE')) { if (!file_put_contents(LOG_CURRENT_FILE, $message, FILE_APPEND)) { echo "Logfile not Write-able, please check your file Permissions"; @@ -85,25 +91,24 @@ function logMessage($message, $eol = true) { } // Autoload Function that loads ManiaControl Class Files on Demand -spl_autoload_register( - function ($className) { - $classPath = str_replace('\\', DIRECTORY_SEPARATOR, $className); - - // Core file - $classDirectoryPath = preg_replace('/ManiaControl/', 'core', $classPath, 1); - $filePath = ManiaControlDir . DIRECTORY_SEPARATOR . $classDirectoryPath . '.php'; - if (file_exists($filePath)) { - require_once $filePath; - return; - } - - // Plugin file - $filePath = ManiaControlDir . DIRECTORY_SEPARATOR . 'plugins/' . $classPath . '.php'; - if (file_exists($filePath)) { - require_once $filePath; - return; - } - }); +spl_autoload_register(function ($className) { + $classPath = str_replace('\\', DIRECTORY_SEPARATOR, $className); + + // Core file + $classDirectoryPath = preg_replace('/ManiaControl/', 'core', $classPath, 1); + $filePath = ManiaControlDir . DIRECTORY_SEPARATOR . $classDirectoryPath . '.php'; + if (file_exists($filePath)) { + require_once $filePath; + return; + } + + // Plugin file + $filePath = ManiaControlDir . DIRECTORY_SEPARATOR . 'plugins/' . $classPath . '.php'; + if (file_exists($filePath)) { + require_once $filePath; + return; + } +}); // Start ManiaControl $maniaControl = new \ManiaControl\ManiaControl();