Add Logger class for managing application logging

This commit is contained in:
netkas 2024-10-30 15:13:04 -04:00
parent 99a4f20ece
commit 7a6d78ac9d

View file

@ -0,0 +1,31 @@
<?php
namespace Socialbox\Classes;
use LogLib\Log;
use function Symfony\Component\String\s;
class Logger
{
private static ?\LogLib\Logger $logger = null;
/**
* @return \LogLib\Logger
*/
public static function getLogger(): \LogLib\Logger
{
if(self::$logger === null)
{
self::$logger = new \LogLib\Logger("net.nosial.socialbox");
self::$logger->setConsoleLoggingEnabled(Configuration::getLoggingConfiguration()->isConsoleLoggingEnabled());
self::$logger->setConsoleLoggingLevel(Configuration::getLoggingConfiguration()->getConsoleLoggingLevel());
self::$logger->setFileLoggingEnabled(Configuration::getLoggingConfiguration()->isFileLoggingEnabled());
self::$logger->setFileLoggingLevel(Configuration::getLoggingConfiguration()->getFileLoggingLevel());
Log::registerExceptionHandler();
Log::register(self::$logger);
}
return self::$logger;
}
}