logging: add loglevel to syslog output
This commit is contained in:
@@ -104,31 +104,8 @@ class FroxlorLogger {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($type) {
|
if (self::$crondebug_flag || $type <= LOG_WARNING) { // more severe levels have smaller numbers
|
||||||
case LOG_INFO:
|
echo "[".getLogLevelDesc($type)."] ".$text.PHP_EOL;
|
||||||
$_type = 'information';
|
|
||||||
break;
|
|
||||||
case LOG_NOTICE:
|
|
||||||
$_type = 'notice';
|
|
||||||
break;
|
|
||||||
case LOG_WARNING:
|
|
||||||
$_type = 'warning';
|
|
||||||
break;
|
|
||||||
case LOG_ERR:
|
|
||||||
$_type = 'error';
|
|
||||||
break;
|
|
||||||
case LOG_CRIT:
|
|
||||||
$_type = 'critical';
|
|
||||||
break;
|
|
||||||
case LOG_DEBUG:
|
|
||||||
$_type = 'debug';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$_type = 'unknown';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (self::$crondebug_flag || $type <= LOG_WARNING) { # more severe levels have smaller numbers
|
|
||||||
echo "[".$_type."] ".$text.PHP_EOL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings::Get('logger.log_cron') == '0'
|
if (Settings::Get('logger.log_cron') == '0'
|
||||||
|
|||||||
@@ -114,9 +114,9 @@ class SysLogger extends AbstractLogger {
|
|||||||
if ($text != null
|
if ($text != null
|
||||||
&& $text != ''
|
&& $text != ''
|
||||||
) {
|
) {
|
||||||
syslog((int)$type, "[" . ucfirst($_action) . " Action " . $name . "] " . $text);
|
syslog((int)$type, "[" . ucfirst($_action) . " Action " . $name . "] [".getLogLevelDesc($type)."] " . $text);
|
||||||
} else {
|
} else {
|
||||||
syslog((int)$type, "[" . ucfirst($_action) . " Action " . $name . "] No text given!!! Check scripts!");
|
syslog((int)$type, "[" . ucfirst($_action) . " Action " . $name . "] [".getLogLevelDesc($type)."] No text given!!! Check scripts!");
|
||||||
}
|
}
|
||||||
|
|
||||||
closelog();
|
closelog();
|
||||||
|
|||||||
44
lib/functions/logger/function.getLogLevelDesc.php
Normal file
44
lib/functions/logger/function.getLogLevelDesc.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of the Froxlor project.
|
||||||
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the COPYING
|
||||||
|
* file that was distributed with this source code. You can also view the
|
||||||
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
*
|
||||||
|
* @copyright (c) the authors
|
||||||
|
* @author Michael Kaufmann <mkaufmann@nutime.de>
|
||||||
|
* @author Daniel Reichelt <hacking@nachtgeist.net> (2016-)
|
||||||
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
* @package Functions
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getLogLevelDesc($type) {
|
||||||
|
switch($type) {
|
||||||
|
case LOG_INFO:
|
||||||
|
$_type = 'information';
|
||||||
|
break;
|
||||||
|
case LOG_NOTICE:
|
||||||
|
$_type = 'notice';
|
||||||
|
break;
|
||||||
|
case LOG_WARNING:
|
||||||
|
$_type = 'warning';
|
||||||
|
break;
|
||||||
|
case LOG_ERR:
|
||||||
|
$_type = 'error';
|
||||||
|
break;
|
||||||
|
case LOG_CRIT:
|
||||||
|
$_type = 'critical';
|
||||||
|
break;
|
||||||
|
case LOG_DEBUG:
|
||||||
|
$_type = 'debug';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$_type = 'unknown';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $_type;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user