-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Cron)/Logging: provide logger factory
- Loading branch information
Showing
4 changed files
with
62 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,14 +28,15 @@ | |
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy; | ||
use ILIAS\DI\Container; | ||
use Monolog\Processor\PsrLogMessageProcessor; | ||
use ILIAS\Logging\LoggerFactory; | ||
|
||
/** | ||
* Logging factory | ||
* | ||
* @author Stefan Meyer <[email protected]> | ||
* | ||
*/ | ||
class ilLoggerFactory | ||
class ilLoggerFactory implements LoggerFactory | ||
{ | ||
protected const DEFAULT_FORMAT = "[%suid%] [%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"; | ||
|
||
|
@@ -45,8 +46,7 @@ class ilLoggerFactory | |
|
||
private static ?ilLoggerFactory $instance = null; | ||
|
||
private ilLoggingSettings $settings; | ||
protected Container $dic; | ||
protected ?Container $dic; | ||
|
||
private bool $enabled = false; //ToDo PHP8 Review: This is a private var never read only written and should probably be removed. | ||
|
||
|
@@ -55,19 +55,21 @@ class ilLoggerFactory | |
*/ | ||
private array $loggers = array(); | ||
|
||
protected function __construct(ilLoggingSettings $settings) | ||
{ | ||
protected function __construct( | ||
private ilLoggingSettings $settings | ||
) { | ||
global $DIC; | ||
|
||
$this->dic = $DIC; | ||
$this->settings = $settings; | ||
$this->enabled = $this->getSettings()->isEnabled(); | ||
} | ||
|
||
public static function getInstance(): ilLoggerFactory | ||
public static function getInstance(?\ilLoggingSettings $settings = null): ilLoggerFactory | ||
{ | ||
if (!static::$instance instanceof ilLoggerFactory) { | ||
if (is_null($settings)) { | ||
$settings = ilLoggingDBSettings::getInstance(); | ||
static::$instance = null; | ||
} | ||
if (!static::$instance instanceof ilLoggerFactory) { | ||
static::$instance = new ilLoggerFactory($settings); | ||
} | ||
return static::$instance; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,4 @@ | |
|
||
interface LoggerFactory | ||
{ | ||
|
||
} |