Add plugins version to logs
[MAILPOET-4735]
This commit is contained in:
@ -82,6 +82,9 @@ class LoggerFactory {
|
||||
$this->loggerInstances[$name]->pushProcessor(new MemoryUsageProcessor());
|
||||
}
|
||||
|
||||
// Adds the plugin's versions to the log, we always want to see this
|
||||
$this->loggerInstances[$name]->pushProcessor(new PluginVersionProcessor());
|
||||
|
||||
$this->loggerInstances[$name]->pushHandler(new LogHandler(
|
||||
$this->logRepository,
|
||||
$this->entityManager,
|
||||
|
13
mailpoet/lib/Logging/PluginVersionProcessor.php
Normal file
13
mailpoet/lib/Logging/PluginVersionProcessor.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php declare (strict_types=1);
|
||||
|
||||
namespace MailPoet\Logging;
|
||||
|
||||
use MailPoet\Config\Env;
|
||||
|
||||
class PluginVersionProcessor {
|
||||
public function __invoke(array $record): array {
|
||||
$record['extra']['free_plugin_version'] = Env::$version;
|
||||
$record['extra']['premium_plugin_version'] = defined('MAILPOET_PREMIUM_VERSION') ? MAILPOET_PREMIUM_VERSION : 'premium not installed';
|
||||
return $record;
|
||||
}
|
||||
}
|
@ -39,13 +39,13 @@ class LoggerFactoryTest extends \MailPoetUnitTest {
|
||||
public function testItAttachesProcessors() {
|
||||
$logger1 = $this->loggerFactory->getLogger('logger-with-processors', true);
|
||||
$processors = $logger1->getProcessors();
|
||||
expect($processors)->notEmpty();
|
||||
expect(count($processors))->greaterThan(1);
|
||||
}
|
||||
|
||||
public function testItDoesNotAttachProcessors() {
|
||||
$logger1 = $this->loggerFactory->getLogger('logger-without-processors', false);
|
||||
$processors = $logger1->getProcessors();
|
||||
expect($processors)->isEmpty();
|
||||
expect($processors)->count(1);
|
||||
}
|
||||
|
||||
public function testItAttachesHandler() {
|
||||
|
Reference in New Issue
Block a user