Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
TASK: remove loggerMananger and use Core/LogManger to have the same r…
Browse files Browse the repository at this point in the history
…equestIf of logging entries
  • Loading branch information
ursulaklinger authored and kabarakh committed Oct 21, 2020
1 parent b51ecb1 commit b272e49
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 618 deletions.
36 changes: 20 additions & 16 deletions Classes/Logger/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
***************************************************************/

use PunktDe\PtExtbase\Logger\Processor\ReplaceComponentProcessor;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Log\LogLevel;

Expand All @@ -31,9 +32,9 @@
class Logger implements SingletonInterface
{
/**
* @var LoggerManager
* @var LogManager
*/
protected $loggerManager;
protected $logManager;

/**
* @var \TYPO3\CMS\Core\Log\Logger
Expand Down Expand Up @@ -75,11 +76,11 @@ public function __construct()
}

/**
* @param LoggerManager $loggerManager
* @param LogManager $logManager
*/
public function injectLoggerManager(LoggerManager $loggerManager)
public function injectLogManager(LogManager $logManager)
{
$this->loggerManager = $loggerManager;
$this->logManager = $logManager;
}

/**
Expand Down Expand Up @@ -123,14 +124,6 @@ protected function configureLoggerProperties()
$GLOBALS['TYPO3_CONF_VARS']['LOG']['processorConfiguration'][LogLevel::DEBUG] = [
ReplaceComponentProcessor::class => []
];

$internalName = LogLevel::getInternalName($this->loggerConfiguration->getEmailLogLevelThreshold());

if ($this->loggerConfiguration->weHaveAnyEmailReceivers()) {
$GLOBALS['TYPO3_CONF_VARS']['LOG']['processorConfiguration'][$internalName]['Tx_PtExtbase_Logger_Processor_EmailProcessor'] = [
'receivers' => $this->loggerConfiguration->getEmailReceivers()
];
}
}


Expand All @@ -144,7 +137,7 @@ protected function getLogger($logComponent)
if ($logComponent === null) {
$logComponent = $this->defaultLogComponent;
}
return $this->logger = $this->loggerManager->getLogger($logComponent);
return $this->logger = $this->logManager->getLogger($logComponent);
}


Expand Down Expand Up @@ -400,9 +393,9 @@ public function enrichLogDataByComponent(&$data, $component)
$this->enrichLoggerSpecificDataByComponent($data, $component);

if (empty($component)) {
$data['loggerComponent'] = $this->loggerManager->unifyComponentName($this->defaultLogComponent);
$data['loggerComponent'] = $this->unifyComponentName($this->defaultLogComponent);
} else {
$data['loggerComponent'] = $this->loggerManager->unifyComponentName($component);
$data['loggerComponent'] = $this->unifyComponentName($component);
}

return $this;
Expand All @@ -415,4 +408,15 @@ public function enrichLogDataByComponent(&$data, $component)
public function enrichLoggerSpecificDataByComponent(&$data, $component)
{
}
/**
* Transform namespaces and underscore class names to the dot-name style
*
* @param $componentName
* @return string
*/
public function unifyComponentName($componentName)
{
$separators = ['_', '\\'];
return str_replace($separators, '.', $componentName);
}
}
68 changes: 0 additions & 68 deletions Classes/Logger/LoggerConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,12 @@ class LoggerConfiguration implements SingletonInterface
*/
protected $logLevelThreshold = 6;


/**
* @var integer
*/
protected $emailLogLevelThreshold = 2;


/**
* @var string
*/
protected $emailReceivers = '';


public function __construct()
{
$this->extensionConfiguration = Div::returnExtConfArray('pt_extbase');
$this->evaluateLogFilePath();
$this->evaluateExceptionDirectory();
$this->setLogLevelThresholdByExtensionConfigurationProperty('logLevelThreshold');
$this->setLogLevelThresholdByExtensionConfigurationProperty('emailLogLevelThreshold');
$this->evaluateEmailReceivers();
}


Expand Down Expand Up @@ -123,32 +108,6 @@ protected function setLogLevelThresholdByExtensionConfigurationProperty($propert
}
}



/**
* @return void
*
* TODO: Add some logic to check if e-mail addresses are syntactically valid
*/
protected function evaluateEmailReceivers()
{
if (array_key_exists('emailReceivers', $this->extensionConfiguration)) {
$this->emailReceivers = $this->extensionConfiguration['emailReceivers'];
}
}



/**
* @return int
*/
public function getEmailLogLevelThreshold()
{
return $this->emailLogLevelThreshold;
}



/**
* @return string
*/
Expand All @@ -157,8 +116,6 @@ public function getExceptionDirectory()
return $this->exceptionDirectory;
}



/**
* @return string
*/
Expand All @@ -167,36 +124,11 @@ public function getLogFilePath()
return $this->logFilePath;
}



/**
* @return int
*/
public function getLogLevelThreshold()
{
return $this->logLevelThreshold;
}



/**
* @return string
*/
public function getEmailReceivers()
{
return $this->emailReceivers;
}



/**
* @return boolean
*/
public function weHaveAnyEmailReceivers()
{
if ($this->emailReceivers === '') {
return false;
}
return true;
}
}
125 changes: 0 additions & 125 deletions Classes/Logger/LoggerManager.php

This file was deleted.

Loading

0 comments on commit b272e49

Please sign in to comment.