4 include_once
'./libs/composer/vendor/autoload.php';
5 include_once
'./Services/Logging/classes/public/class.ilLogLevel.php';
23 const DEFAULT_FORMAT =
"[%suid%] [%datetime%] %channel%.%level_name%: %message% %context% %extra%\n";
48 if (!static::$instance) {
49 include_once
'./Services/Logging/classes/class.ilLoggingDBSettings.php';
53 return static::$instance;
63 return static::$instance =
new self(
$settings);
77 return $factory->getComponentLogger($a_component_id);
87 return $factory->getComponentLogger(self::ROOT_LOGGER);
98 if (!$this->
getSettings()->isBrowserLogEnabledForUser($a_login)) {
102 include_once(
"./Services/Logging/classes/extensions/class.ilLineFormatter.php");
104 foreach ($this->loggers as $a_component_id => $logger) {
106 $browser_handler =
new BrowserConsoleHandler();
107 $browser_handler->setLevel($this->
getSettings()->getLevelByComponent($a_component_id));
108 $browser_handler->setFormatter(
new ilLineFormatter(static::DEFAULT_FORMAT,
'Y-m-d H:i:s.u',
true,
true));
109 $logger->getLogger()->pushHandler($browser_handler);
124 if (isset(
$_SERVER[
'HTTP_ACCEPT']) && strpos(
$_SERVER[
'HTTP_ACCEPT'],
'text/html') !==
false) {
129 if (isset(
$_SERVER[
'HTTP_ACCEPT']) && strpos(
$_SERVER[
'HTTP_ACCEPT'],
'application/json') !==
false) {
134 if ((isset(
$_GET[
'cmdMode']) &&
$_GET[
'cmdMode'] ===
'asynch') || (
136 strtolower(
$GLOBALS[
'DIC']->
http()->request()->getServerParams()[
'HTTP_X_REQUESTED_WITH'] ??
'') ===
'xmlhttprequest' 169 if (isset($this->loggers[$a_component_id])) {
170 return $this->loggers[$a_component_id];
173 $loggerNamePrefix =
'';
174 if (defined(
'CLIENT_ID')) {
178 switch ($a_component_id) {
180 $logger =
new Logger($loggerNamePrefix .
'root');
184 $logger =
new Logger($loggerNamePrefix . $a_component_id);
190 $null_handler =
new NullHandler();
191 $logger->pushHandler($null_handler);
193 include_once
'./Services/Logging/classes/class.ilComponentLogger.php';
199 $stream_handler =
new StreamHandler(
204 if ($a_component_id == self::ROOT_LOGGER) {
205 $stream_handler->setLevel($this->
getSettings()->getLevelByComponent(self::COMPONENT_ROOT));
207 $stream_handler->setLevel($this->
getSettings()->getLevelByComponent($a_component_id));
211 include_once(
"./Services/Logging/classes/extensions/class.ilLineFormatter.php");
212 $line_formatter =
new ilLineFormatter(static::DEFAULT_FORMAT,
'Y-m-d H:i:s.u',
true,
true);
213 $stream_handler->setFormatter($line_formatter);
217 $finger_crossed_handler =
new FingersCrossedHandler(
219 new ErrorLevelActivationStrategy($this->
getSettings()->getCacheLevel()),
222 $logger->pushHandler($finger_crossed_handler);
224 $logger->pushHandler($stream_handler);
228 $GLOBALS[
'DIC']->offsetExists(
'ilUser') &&
233 $browser_handler =
new BrowserConsoleHandler();
234 #$browser_handler->setLevel($this->getSettings()->getLevelByComponent($a_component_id)); 235 $browser_handler->setLevel($this->
getSettings()->getLevel());
236 $browser_handler->setFormatter($line_formatter);
237 $logger->pushHandler($browser_handler);
244 $logger->pushProcessor(
function ($record) {
245 $record[
'suid'] = substr(session_id(), 0, 5);
250 include_once
'./Services/Logging/classes/extensions/class.ilTraceProcessor.php';
255 include_once
'./Services/Logging/classes/class.ilComponentLogger.php';
258 return $this->loggers[$a_component_id];
getSettings()
Get settigns.
static newInstance(ilLoggingSettings $settings)
get new instance
Component logger with individual log levels by component id.
initUser($a_login)
Init user specific log options.
static http()
Fetches the global http state from ILIAS.
isConsoleAvailable()
Check if console handler is available.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
getComponentLogger($a_component_id)
Get component logger.
static getInstance()
Get instance.
static getLogger($a_component_id)
Get component logger.
__construct(ilLoggingSettings $settings)
static getType()
Get context type.
static getRootLogger()
The unique root logger has a fixed error level.