config = $config; $this->debug = (bool) $config->get('system', 'debugging') ?? false; $this->logLevel = (string) $config->get('system', 'loglevel') ?? LogLevel::NOTICE; $this->profiling = (bool) $config->get('system', 'profiling') ?? false; $this->logChannel = LogChannel::DEFAULT; } public function changeLogChannel(string $logChannel): void { $this->logChannel = $logChannel; self::$logger = null; } /** * (Creates and) Returns the logger instance */ public function getLogger(): LoggerInterface { if (self::$logger === null) { self::$logger = $this->createProfiledLogger(); } return self::$logger; } private function createProfiledLogger(): LoggerInterface { // Always return NullLogger if debug is disabled if ($this->debug === false) { $logger = new NullLogger(); } else { $logger = $this->createLogger($this->logLevel, $this->logChannel); } if ($this->profiling === true) { $profiler = new Profiler($this->config); $logger = new ProfilerLogger($logger, $profiler); } return $logger; } private function createLogger(string $logLevel, string $logChannel): LoggerInterface { return new NullLogger(); } }