use error_log function to write the log
This commit is contained in:
parent
b1decafc1d
commit
9e791f1e58
@ -4,9 +4,9 @@
|
|||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
// Run configuration
|
// Run configuration
|
||||||
|
define('DEV_MODE', false); // Development mode to not send error reports etc.
|
||||||
define('LOG_NAME_USE_DATE', true); // Use current date as suffix for log file name in logs folder
|
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('LOG_NAME_USE_PID', true); // Use current process id as suffix for log file name in logs folder
|
||||||
define('DEV_MODE', false); // Development mode to not send error reports etc.
|
|
||||||
|
|
||||||
// Define base dir
|
// Define base dir
|
||||||
define('ManiaControlDir', __DIR__ . DIRECTORY_SEPARATOR);
|
define('ManiaControlDir', __DIR__ . DIRECTORY_SEPARATOR);
|
||||||
@ -33,34 +33,17 @@ if (LOG_NAME_USE_PID) {
|
|||||||
$logFileName .= '_' . getmypid();
|
$logFileName .= '_' . getmypid();
|
||||||
}
|
}
|
||||||
$logFileName .= '.log';
|
$logFileName .= '.log';
|
||||||
define('LOG_FILE', $logFileName);
|
ini_set('error_log', $logFileName);
|
||||||
ini_set('error_log', LOG_FILE);
|
|
||||||
@file_put_contents(LOG_FILE, '');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log and echo the given text
|
* Log and echo the given text
|
||||||
*
|
*
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param bool $eol
|
* @param bool $eol
|
||||||
* @param bool $date
|
|
||||||
*/
|
*/
|
||||||
function logMessage($message, $eol = true, $date = true) {
|
function logMessage($message, $eol = true) {
|
||||||
if ($date) {
|
error_log($message);
|
||||||
$date = date('d.M y H:i:s');
|
echo $message . ($eol ? PHP_EOL : '');
|
||||||
$message = $date . ' ' . $message;
|
|
||||||
}
|
|
||||||
if ($eol) {
|
|
||||||
$message .= PHP_EOL;
|
|
||||||
}
|
|
||||||
if (defined('LOG_CURRENT_FILE')) {
|
|
||||||
if (!is_writable(LOG_CURRENT_FILE) || !file_put_contents(LOG_CURRENT_FILE, $message, FILE_APPEND)) {
|
|
||||||
echo 'Current-Logfile not write-able, please check the File Permissions!';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!is_writable(LOG_FILE) || !file_put_contents(LOG_FILE, $message, FILE_APPEND)) {
|
|
||||||
echo 'Logfile not write-able, please check the File Permissions!';
|
|
||||||
}
|
|
||||||
echo $message;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logMessage('Starting ManiaControl...');
|
logMessage('Starting ManiaControl...');
|
||||||
@ -71,10 +54,10 @@ logMessage('Starting ManiaControl ...');
|
|||||||
define('MIN_PHP_VERSION', '5.4');
|
define('MIN_PHP_VERSION', '5.4');
|
||||||
logMessage('Checking for minimum required PHP-Version ' . MIN_PHP_VERSION . ' ... ', false);
|
logMessage('Checking for minimum required PHP-Version ' . MIN_PHP_VERSION . ' ... ', false);
|
||||||
if (phpversion() >= MIN_PHP_VERSION) {
|
if (phpversion() >= MIN_PHP_VERSION) {
|
||||||
logMessage(phpversion() . " OK!", true, false);
|
logMessage(phpversion() . " OK!", true);
|
||||||
} else {
|
} else {
|
||||||
logMessage('TOO OLD VERSION!', true, false);
|
logMessage('TOO OLD VERSION!', true);
|
||||||
logMessage(' -- Make sure that you install at least PHP 5.4', true, false);
|
logMessage(' -- Make sure that you install at least PHP 5.4', true);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,19 +68,19 @@ if (phpversion() >= MIN_PHP_VERSION) {
|
|||||||
*/
|
*/
|
||||||
logMessage('Checking for installed MySQLi ... ', false);
|
logMessage('Checking for installed MySQLi ... ', false);
|
||||||
if (extension_loaded('mysqli')) {
|
if (extension_loaded('mysqli')) {
|
||||||
logMessage('FOUND!', true, false);
|
logMessage('FOUND!', true);
|
||||||
} else {
|
} else {
|
||||||
logMessage('NOT FOUND!', true, false);
|
logMessage('NOT FOUND!', true);
|
||||||
logMessage(' -- You don\'t have MySQLi installed, make sure to check: http://www.php.net/manual/en/mysqli.installation.php', true, false);
|
logMessage(' -- You don\'t have MySQLi installed, make sure to check: http://www.php.net/manual/en/mysqli.installation.php', true);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
logMessage('Checking for installed cURL ... ', false);
|
logMessage('Checking for installed cURL ... ', false);
|
||||||
if (extension_loaded('curl')) {
|
if (extension_loaded('curl')) {
|
||||||
logMessage('FOUND!', true, false);
|
logMessage('FOUND!', true);
|
||||||
} else {
|
} else {
|
||||||
logMessage('NOT FOUND!', true, false);
|
logMessage('NOT FOUND!', true);
|
||||||
logMessage('You don\'t have cURL installed, make sure to check: http://www.php.net/manual/en/curl.installation.php', true, false);
|
logMessage('You don\'t have cURL installed, make sure to check: http://www.php.net/manual/en/curl.installation.php', true);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user