Logger Class
This commit is contained in:
parent
2ff88c230b
commit
621c795a54
@ -23,26 +23,15 @@ if (!ini_get('date.timezone') && function_exists('date_default_timezone_set')) {
|
|||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Make sure garbage collection is enabled
|
||||||
* Build log file name
|
gc_enable();
|
||||||
*/
|
|
||||||
function buildLogFileName() {
|
|
||||||
$logFileName = ManiaControlDir . 'logs' . DIRECTORY_SEPARATOR;
|
|
||||||
if (!is_dir($logFileName) && !mkdir($logFileName)) {
|
|
||||||
echo "Couldn't create Logs Folder, please check the File Permissions!";
|
|
||||||
}
|
|
||||||
$logFileName .= 'ManiaControl';
|
|
||||||
if (LOG_NAME_USE_DATE) {
|
|
||||||
$logFileName .= '_' . date('Y-m-d');
|
|
||||||
}
|
|
||||||
if (LOG_NAME_USE_PID) {
|
|
||||||
$logFileName .= '_' . getmypid();
|
|
||||||
}
|
|
||||||
$logFileName .= '.log';
|
|
||||||
ini_set('error_log', $logFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
buildLogFileName();
|
// Register AutoLoader
|
||||||
|
require_once ManiaControlDir . 'core' . DIRECTORY_SEPARATOR . 'AutoLoader.php';
|
||||||
|
\ManiaControl\AutoLoader::register();
|
||||||
|
|
||||||
|
// Setup Logger
|
||||||
|
\ManiaControl\Logger::setup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log and echo the given text
|
* Log and echo the given text
|
||||||
@ -95,13 +84,6 @@ function checkRequirements() {
|
|||||||
|
|
||||||
checkRequirements();
|
checkRequirements();
|
||||||
|
|
||||||
// Make sure garbage collection is enabled
|
|
||||||
gc_enable();
|
|
||||||
|
|
||||||
// Register AutoLoader
|
|
||||||
require_once ManiaControlDir . 'core' . DIRECTORY_SEPARATOR . 'AutoLoader.php';
|
|
||||||
\ManiaControl\AutoLoader::register();
|
|
||||||
|
|
||||||
// Start ManiaControl
|
// Start ManiaControl
|
||||||
$maniaControl = new \ManiaControl\ManiaControl();
|
$maniaControl = new \ManiaControl\ManiaControl();
|
||||||
$maniaControl->run();
|
$maniaControl->run();
|
||||||
|
32
application/core/Logger.php
Normal file
32
application/core/Logger.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ManiaControl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ManiaControl Logger Class
|
||||||
|
*
|
||||||
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||||
|
* @copyright 2014 ManiaControl Team
|
||||||
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
|
*/
|
||||||
|
class Logger {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup the Logging Mechanism
|
||||||
|
*/
|
||||||
|
public static function setup() {
|
||||||
|
$logFileName = ManiaControlDir . 'logs' . DIRECTORY_SEPARATOR;
|
||||||
|
if (!is_dir($logFileName) && !mkdir($logFileName)) {
|
||||||
|
echo "Couldn't create Logs Folder, please check the File Permissions!";
|
||||||
|
}
|
||||||
|
$logFileName .= 'ManiaControl';
|
||||||
|
if (LOG_NAME_USE_DATE) {
|
||||||
|
$logFileName .= '_' . date('Y-m-d');
|
||||||
|
}
|
||||||
|
if (LOG_NAME_USE_PID) {
|
||||||
|
$logFileName .= '_' . getmypid();
|
||||||
|
}
|
||||||
|
$logFileName .= '.log';
|
||||||
|
ini_set('error_log', $logFileName);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user