kopia lustrzana https://github.com/friendica/friendica
Bugfixing legacy loglevel
rodzic
c38782731f
commit
9e0be97703
|
@ -83,9 +83,7 @@ class Logger extends BaseObject
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_int($loglevel)) {
|
$loglevel = self::mapLegacyConfigDebugLevel((string)$loglevel);
|
||||||
$loglevel = self::mapLegacyConfigDebugLevel($loglevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
LoggerFactory::addStreamHandler($logger, $logfile, $loglevel);
|
LoggerFactory::addStreamHandler($logger, $logfile, $loglevel);
|
||||||
|
|
||||||
|
@ -107,7 +105,7 @@ class Logger extends BaseObject
|
||||||
* Mapping a legacy level to the PSR-3 compliant levels
|
* Mapping a legacy level to the PSR-3 compliant levels
|
||||||
* @see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#5-psrlogloglevel
|
* @see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#5-psrlogloglevel
|
||||||
*
|
*
|
||||||
* @param int $level the level to be mapped
|
* @param mixed $level the level to be mapped
|
||||||
*
|
*
|
||||||
* @return string the PSR-3 compliant level
|
* @return string the PSR-3 compliant level
|
||||||
*/
|
*/
|
||||||
|
@ -115,26 +113,26 @@ class Logger extends BaseObject
|
||||||
{
|
{
|
||||||
switch ($level) {
|
switch ($level) {
|
||||||
// legacy WARNING
|
// legacy WARNING
|
||||||
case 0:
|
case "0":
|
||||||
return LogLevel::ERROR;
|
return LogLevel::ERROR;
|
||||||
// legacy INFO
|
// legacy INFO
|
||||||
case 1:
|
case "1":
|
||||||
return LogLevel::WARNING;
|
return LogLevel::WARNING;
|
||||||
// legacy TRACE
|
// legacy TRACE
|
||||||
case 2:
|
case "2":
|
||||||
return LogLevel::NOTICE;
|
return LogLevel::NOTICE;
|
||||||
// legacy DEBUG
|
// legacy DEBUG
|
||||||
case 3:
|
case "3":
|
||||||
return LogLevel::INFO;
|
return LogLevel::INFO;
|
||||||
// legacy DATA
|
// legacy DATA
|
||||||
case 4:
|
case "4":
|
||||||
return LogLevel::DEBUG;
|
return LogLevel::DEBUG;
|
||||||
// legacy ALL
|
// legacy ALL
|
||||||
case 5:
|
case "5":
|
||||||
return LogLevel::DEBUG;
|
return LogLevel::DEBUG;
|
||||||
// default if nothing set
|
// default if nothing set
|
||||||
default:
|
default:
|
||||||
return LogLevel::NOTICE;
|
return $level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,13 @@ class LoggerFactory
|
||||||
public static function addStreamHandler($logger, $stream, $level = LogLevel::NOTICE)
|
public static function addStreamHandler($logger, $stream, $level = LogLevel::NOTICE)
|
||||||
{
|
{
|
||||||
if ($logger instanceof Monolog\Logger) {
|
if ($logger instanceof Monolog\Logger) {
|
||||||
$fileHandler = new Monolog\Handler\StreamHandler($stream, Monolog\Logger::toMonologLevel($level));
|
$loglevel = Monolog\Logger::toMonologLevel($level);
|
||||||
|
|
||||||
|
// fallback to notice if an invalid loglevel is set
|
||||||
|
if (!is_int($loglevel)) {
|
||||||
|
$loglevel = LogLevel::NOTICE;
|
||||||
|
}
|
||||||
|
$fileHandler = new Monolog\Handler\StreamHandler($stream, $loglevel);
|
||||||
|
|
||||||
$formatter = new Monolog\Formatter\LineFormatter("%datetime% %channel% [%level_name%]: %message% %context% %extra%\n");
|
$formatter = new Monolog\Formatter\LineFormatter("%datetime% %channel% [%level_name%]: %message% %context% %extra%\n");
|
||||||
$fileHandler->setFormatter($formatter);
|
$fileHandler->setFormatter($formatter);
|
||||||
|
|
Ładowanie…
Reference in New Issue