Merge pull request #1799 from MPOS/debug-to-logfile
[IMPROVED] Allow debug console log to logfile
This commit is contained in:
commit
dc1fe9aa35
@ -10,9 +10,9 @@ if (empty($config['algorithm']) || $config['algorithm'] == 'scrypt') {
|
||||
}
|
||||
|
||||
// Default classes
|
||||
require_once(CLASS_DIR . '/debug.class.php');
|
||||
require_once(INCLUDE_DIR . '/lib/KLogger.php');
|
||||
require_once(CLASS_DIR . '/logger.class.php');
|
||||
require_once(CLASS_DIR . '/debug.class.php');
|
||||
if ($config['mysql_filter']) {
|
||||
require_once(CLASS_DIR . '/strict.class.php');
|
||||
}
|
||||
|
||||
@ -31,7 +31,8 @@ class Debug {
|
||||
* @param integer $DEBUG [optional] Enable (>=1) or disable (0) debugging
|
||||
* @return none
|
||||
*/
|
||||
function __construct($DEBUG=0) {
|
||||
function __construct($log, $DEBUG=0) {
|
||||
$this->log = $log;
|
||||
$this->DEBUG = $DEBUG;
|
||||
if ($DEBUG >= 1) {
|
||||
$this->floatStartTime = microtime(true);
|
||||
@ -82,6 +83,7 @@ class Debug {
|
||||
'backtrace' => $this->getBacktrace(),
|
||||
'message' => $msg,
|
||||
);
|
||||
$this->log->log("debug", $msg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,5 +110,5 @@ class Debug {
|
||||
}
|
||||
|
||||
// Instantiate this class
|
||||
$debug = new Debug($config['DEBUG']);
|
||||
$debug = new Debug($log, $config['DEBUG']);
|
||||
?>
|
||||
|
||||
@ -7,15 +7,16 @@ class Logger {
|
||||
if ($config['logging']['enabled'] && $config['logging']['level'] > 0) {
|
||||
$this->KLogger = KLogger::instance($config['logging']['path'], $config['logging']['level']);
|
||||
$this->logging = true;
|
||||
$this->floatStartTime = microtime(true);
|
||||
}
|
||||
}
|
||||
public function log($strType, $strMessage) {
|
||||
// Logmask, we add some infos into the KLogger
|
||||
$strMask = "[ %12s ] [ %8s | %-8s ] : %s";
|
||||
$strMask = "[ %12s ] [ %8s | %-8s ] [ %7.7s ] : %s";
|
||||
$strIPAddress = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'unknown';
|
||||
$strPage = isset($_REQUEST['page']) ? $_REQUEST['page'] : 'none';
|
||||
$strAction = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'none';
|
||||
$strMessage = sprintf($strMask, $strIPAddress, $strPage, $strAction, $strMessage);
|
||||
$strMessage = sprintf($strMask, $strIPAddress, $strPage, $strAction, number_format(round((microtime(true) - $this->floatStartTime) * 1000, 2), 2), $strMessage);
|
||||
if ($this->logging) {
|
||||
switch ($strType) {
|
||||
case 'emerg':
|
||||
|
||||
Loading…
Reference in New Issue
Block a user