Use a 3rd party normalizer for the logger
This commit is contained in:
parent
846b826867
commit
f140084a8d
|
@ -3,6 +3,7 @@
|
||||||
* @author Bart Visscher <bartv@thisnet.nl>
|
* @author Bart Visscher <bartv@thisnet.nl>
|
||||||
* @author Bernhard Posselt <dev@bernhard-posselt.com>
|
* @author Bernhard Posselt <dev@bernhard-posselt.com>
|
||||||
* @author Morris Jobke <hey@morrisjobke.de>
|
* @author Morris Jobke <hey@morrisjobke.de>
|
||||||
|
* @author Olivier Paroz <owncloud@oparoz.com>
|
||||||
* @author Robin Appelman <icewind@owncloud.com>
|
* @author Robin Appelman <icewind@owncloud.com>
|
||||||
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
||||||
* @author Victor Dubiniuk <dubiniuk@owncloud.com>
|
* @author Victor Dubiniuk <dubiniuk@owncloud.com>
|
||||||
|
@ -26,6 +27,8 @@
|
||||||
|
|
||||||
namespace OC;
|
namespace OC;
|
||||||
|
|
||||||
|
use InterfaSys\LogNormalizer\Normalizer;
|
||||||
|
|
||||||
use \OCP\ILogger;
|
use \OCP\ILogger;
|
||||||
use OCP\Security\StringUtils;
|
use OCP\Security\StringUtils;
|
||||||
|
|
||||||
|
@ -48,12 +51,15 @@ class Log implements ILogger {
|
||||||
|
|
||||||
/** @var boolean|null cache the result of the log condition check for the request */
|
/** @var boolean|null cache the result of the log condition check for the request */
|
||||||
private $logConditionSatisfied = null;
|
private $logConditionSatisfied = null;
|
||||||
|
/** @var Normalizer */
|
||||||
|
private $normalizer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $logger The logger that should be used
|
* @param string $logger The logger that should be used
|
||||||
* @param SystemConfig $config the system config object
|
* @param SystemConfig $config the system config object
|
||||||
|
* @param null $normalizer
|
||||||
*/
|
*/
|
||||||
public function __construct($logger=null, SystemConfig $config=null) {
|
public function __construct($logger=null, SystemConfig $config=null, $normalizer = null) {
|
||||||
// FIXME: Add this for backwards compatibility, should be fixed at some point probably
|
// FIXME: Add this for backwards compatibility, should be fixed at some point probably
|
||||||
if($config === null) {
|
if($config === null) {
|
||||||
$config = \OC::$server->getSystemConfig();
|
$config = \OC::$server->getSystemConfig();
|
||||||
|
@ -68,6 +74,11 @@ class Log implements ILogger {
|
||||||
} else {
|
} else {
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
}
|
}
|
||||||
|
if ($normalizer === null) {
|
||||||
|
$this->normalizer = new Normalizer();
|
||||||
|
} else {
|
||||||
|
$this->normalizer = $normalizer;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +186,8 @@ class Log implements ILogger {
|
||||||
$minLevel = min($this->config->getValue('loglevel', \OCP\Util::WARN), \OCP\Util::ERROR);
|
$minLevel = min($this->config->getValue('loglevel', \OCP\Util::WARN), \OCP\Util::ERROR);
|
||||||
$logCondition = $this->config->getValue('log.condition', []);
|
$logCondition = $this->config->getValue('log.condition', []);
|
||||||
|
|
||||||
|
array_walk($context, [$this->normalizer, 'format']);
|
||||||
|
|
||||||
if (isset($context['app'])) {
|
if (isset($context['app'])) {
|
||||||
$app = $context['app'];
|
$app = $context['app'];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue