N°2977 LogAPI : restore default log level to OK, and really allow LEVEL_DEFAULT overloads

* Level was changed by mistake to trace with refactoring in 289171b9
Thanks @v-dumas !

* self wouldn't allow to override
see https://www.php.net/manual/fr/language.oop5.late-static-bindings.php
Thanks @bruno-ds !

* improve PHPDoc !
This commit is contained in:
Pierre Goiffon
2020-05-04 16:12:26 +02:00
parent 7a40db94fb
commit 5d7582bb6f

View File

@@ -542,7 +542,12 @@ abstract class LogAPI
const LEVEL_OK = 'Ok';
const LEVEL_DEBUG = 'Debug';
const LEVEL_TRACE = 'Trace';
const LEVEL_DEFAULT = self::LEVEL_TRACE;
/**
* @var string default log level, can be overrided
* @see GetMinLogLevel
* @since 2.7.1 N°2977
*/
const LEVEL_DEFAULT = self::LEVEL_OK;
protected static $aLevelsPriority = array(
self::LEVEL_ERROR => 400,
@@ -640,21 +645,22 @@ abstract class LogAPI
/**
* @param $sChannel
*
* @return mixed|null
* @return string one of the LEVEL_* const value
* @uses LEVEL_DEFAULT
*/
private static function GetMinLogLevel($sChannel)
{
$oConfig = (static::$m_oMockMetaModelConfig !== null) ? static::$m_oMockMetaModelConfig : \MetaModel::GetConfig();
if (!$oConfig instanceof Config)
{
return self::LEVEL_DEFAULT;
return static::LEVEL_DEFAULT;
}
$sLogLevelMin = $oConfig->Get('log_level_min');
if (empty($sLogLevelMin))
{
return self::LEVEL_DEFAULT;
return static::LEVEL_DEFAULT;
}
if (!is_array($sLogLevelMin))
@@ -672,7 +678,7 @@ abstract class LogAPI
return $sLogLevelMin[$sChannel];
}
return self::LEVEL_DEFAULT;
return static::LEVEL_DEFAULT;
}
}