No Code Attached Yet bug
avatar dmitriitux
dmitriitux
14 Oct 2021

in joomla 3.x (but this is also true for joomla 4.x) we faced the problem of registering our loggers. there the namespace is rigidly tied to the kernel, that is, we cannot register our loggers at all. We had to make our layer MyLog extends Log and override the addLogEntry method

In code: https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Log/Log.php#L355

How can this be solved?
We decided in our own way, but I'll write about what can be done here.

if(class_exists($this->configurations[$signature]['logger']))
{
    $class = $this->configurations[$signature]['logger'];
}
else
{
    $class = __NAMESPACE__ . '\\Logger\\' . ucfirst($this->configurations[$signature]['logger']) . 'Logger';

    if (!class_exists($class))
    {
         throw new \RuntimeException('Unable to create a Logger instance: ' . $class);
    }
}

A similar problem applies to registering your Storage classes for Cache: https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Cache/CacheStorage.php#L149

avatar dmitriitux dmitriitux - open - 14 Oct 2021
avatar joomla-cms-bot joomla-cms-bot - change - 14 Oct 2021
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 14 Oct 2021
avatar dmitriitux dmitriitux - change - 14 Oct 2021
The description was changed
avatar dmitriitux dmitriitux - edited - 14 Oct 2021
avatar Hackwar Hackwar - change - 22 Feb 2023
Labels Added: bug
avatar Hackwar Hackwar - labeled - 22 Feb 2023
avatar carlitorweb
carlitorweb - comment - 9 Mar 2023

@Hackwar You can close this issue. Now you can registry your own logger

public function register(string $key, string $class, bool $replace = false)

avatar Fedik Fedik - change - 9 Mar 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-03-09 15:20:51
Closed_By Fedik
avatar Fedik Fedik - close - 9 Mar 2023

Add a Comment

Login with GitHub to post a comment