ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilLoggerFactory Class Reference

Logging factory. More...

+ Collaboration diagram for ilLoggerFactory:

Public Member Functions

 isLoggingEnabled ()
 
 initUser (string $a_login)
 Init user specific log options. More...
 
 getSettings ()
 
 getComponentLogger (string $a_component_id)
 

Static Public Member Functions

static getInstance ()
 
static newInstance (ilLoggingSettings $settings)
 
static getLogger (string $a_component_id)
 Get component logger. More...
 
static getRootLogger ()
 The unique root logger has a fixed error level. More...
 

Protected Member Functions

 __construct (ilLoggingSettings $settings)
 
 isConsoleAvailable ()
 Check if console handler is available. More...
 
 getLoggers ()
 

Protected Attributes

const DEFAULT_FORMAT = "[%extra.suid%] [%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"
 
const ROOT_LOGGER = 'root'
 
const COMPONENT_ROOT = 'log_root'
 
const SETUP_LOGGER = 'setup'
 
Container $dic
 

Private Attributes

ilLoggingSettings $settings
 
bool $enabled = false
 
array $loggers = array()
 

Static Private Attributes

static ilLoggerFactory $instance = null
 

Detailed Description

Logging factory.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 37 of file class.ilLoggerFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ilLoggerFactory::__construct ( ilLoggingSettings  $settings)
protected

Definition at line 57 of file class.ilLoggerFactory.php.

58 {
59 global $DIC;
60
61 $this->dic = $DIC;
62 $this->settings = $settings;
63 $this->enabled = $this->getSettings()->isEnabled();
64 }
ilLoggingSettings $settings
global $DIC
Definition: shib_login.php:26

References $DIC, $settings, getSettings(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ getComponentLogger()

ilLoggerFactory::getComponentLogger ( string  $a_component_id)

Definition at line 170 of file class.ilLoggerFactory.php.

170 : ilLogger
171 {
172 if (isset($this->loggers[$a_component_id])) {
173 return $this->loggers[$a_component_id];
174 }
175
176 $loggerNamePrefix = '';
177 if (defined('CLIENT_ID')) {
178 $loggerNamePrefix = CLIENT_ID . '_';
179 }
180
181 switch ($a_component_id) {
182 case 'root':
183 $logger = new Logger($loggerNamePrefix . 'root');
184 break;
185
186 default:
187 $logger = new Logger($loggerNamePrefix . $a_component_id);
188 break;
189 }
190
191 if (!$this->isLoggingEnabled()) {
192 $null_handler = new NullHandler();
193 $logger->pushHandler($null_handler);
194
195 return $this->loggers[$a_component_id] = new ilComponentLogger($logger);
196 }
197
198
199 // standard stream handler
200 $stream_handler = new StreamHandler(
201 $this->getSettings()->getLogDir() . '/' . $this->getSettings()->getLogFile(),
202 Logger::DEBUG, // default minimum level, will be overwritten by component log level
203 true
204 );
205
206 if ($a_component_id == self::ROOT_LOGGER) {
207 $stream_handler->setLevel($this->getSettings()->getLevelByComponent(self::COMPONENT_ROOT));
208 } else {
209 $stream_handler->setLevel($this->getSettings()->getLevelByComponent($a_component_id));
210 }
211
212 // format lines
213 $line_formatter = new ilLineFormatter(static::DEFAULT_FORMAT, 'Y-m-d H:i:s.u', true, true);
214 $stream_handler->setFormatter($line_formatter);
215
216 if ($this->getSettings()->isCacheEnabled()) {
217 // add new finger crossed handler
218 $finger_crossed_handler = new FingersCrossedHandler(
219 $stream_handler,
220 new ErrorLevelActivationStrategy($this->getSettings()->getCacheLevel()),
221 1000
222 );
223 $logger->pushHandler($finger_crossed_handler);
224 } else {
225 $logger->pushHandler($stream_handler);
226 }
227
228 if (
229 $this->dic->offsetExists('ilUser') &&
230 $this->dic->user() instanceof ilObjUser
231 ) {
232 if ($this->getSettings()->isBrowserLogEnabledForUser($this->dic->user()->getLogin())) {
233 if ($this->isConsoleAvailable()) {
234 $browser_handler = new BrowserConsoleHandler();
235 $browser_handler->setLevel($this->getSettings()->getLevel());
236 $browser_handler->setFormatter($line_formatter);
237 $logger->pushHandler($browser_handler);
238 }
239 }
240 }
241
242
243 // suid log
244 $logger->pushProcessor(function ($record) {
245 $record['extra']['suid'] = substr(session_id(), 0, 5);
246 return $record;
247 });
248
249 // append trace
250 $logger->pushProcessor(new ilTraceProcessor(ilLogLevel::DEBUG));
251
252 // Interpolate context variables.
253 $logger->pushProcessor(new PsrLogMessageProcessor());
254
255 // register new logger
256 $this->loggers[$a_component_id] = new ilComponentLogger($logger);
257
258 return $this->loggers[$a_component_id];
259 }
Component logger with individual log levels by component id.
Custom line formatter.
isConsoleAvailable()
Check if console handler is available.
Component logger with individual log levels by component id.
User class.
const CLIENT_ID
Definition: constants.php:41

References CLIENT_ID, ilLogLevel\DEBUG, ILIAS\MetaData\Editor\Http\DEBUG, getSettings(), isConsoleAvailable(), and isLoggingEnabled().

+ Here is the call graph for this function:

◆ getInstance()

static ilLoggerFactory::getInstance ( )
static

Definition at line 66 of file class.ilLoggerFactory.php.

67 {
68 if (!static::$instance instanceof ilLoggerFactory) {
70 static::$instance = new ilLoggerFactory($settings);
71 }
72 return static::$instance;
73 }

References $settings, and ilLoggingDBSettings\getInstance().

Referenced by ilRbacAdmin\assignUser(), ilRbacAdmin\deassignUser(), getLogger(), getRootLogger(), ilCourseAppEventListener\handleUserAssignments(), ilInitialisation\initILIAS(), and ilInitialisation\initUserAccount().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLogger()

static ilLoggerFactory::getLogger ( string  $a_component_id)
static

Get component logger.

Definition at line 89 of file class.ilLoggerFactory.php.

89 : ilLogger
90 {
91 $factory = self::getInstance();
92 return $factory->getComponentLogger($a_component_id);
93 }

References getInstance().

Referenced by ilObjWikiGUI\__construct(), ilNoteGUI\__construct(), ilObjLoggingSettingsGUI\__construct(), SurveyQuestionGUI\__construct(), ilExAssignment\__construct(), ilObjWorkspaceFolderGUI\__construct(), ilAccess\__construct(), ilRbacReview\__construct(), ilBookCronNotification\__construct(), ilCmiXapiDelCron\__construct(), ilCmiXapiDelModel\__construct(), ilXapiResultsCronjob\__construct(), ILIAS\COPage\PC\Paragraph\ParagraphResponseFactory\__construct(), ilImportMapping\__construct(), ilDataSet\__construct(), ilGlossaryDataSet\__construct(), ilGlossaryTermPermission\__construct(), ilLearningModuleDataSet\__construct(), ilLTIAppEventListener\__construct(), ilLTIDataConnector\__construct(), ilLTIViewGUI\__construct(), ilMediaObjectDataSet\__construct(), ilPDStudyProgrammeSimpleListGUI\__construct(), ilStyleDataSet\__construct(), SurveyCategories\__construct(), ilObjSurveyQuestionPoolGUI\__construct(), ilWikiDataSet\__construct(), ilCheckSumOfWorkspaceFileSizesJob\__construct(), ilCollectWorkspaceFilesJob\__construct(), ilCopyWorkspaceFilesToTempDirectoryJob\__construct(), ilMailAddressTypeFactory\__construct(), ilAppEventHandler\__construct(), ilStartUpGUI\__construct(), ILIAS\LearningModule\Export\LMHtmlExport\__construct(), ILIAS\Wiki\Export\WikiHtmlExport\__construct(), ILIAS\COPage\Editor\Server\Server\__construct(), ilRepoStandardUploadHandlerGUI\__construct(), ilAuthProviderLTI\__construct(), ilExPeerReview\__construct(), ilContainerXmlParser\__construct(), ilLTITool\__construct(), ilSurveyEvaluationGUI\__construct(), ilSurveyExecutionGUI\__construct(), ilSurveySkill\__construct(), ilWikiUserHTMLExport\__construct(), ilPageEditorGUI\__construct(), ilPageContentGUI\__construct(), ilPageContent\__construct(), ilExAssignmentReminder\__construct(), ilGlossaryTermGUI\__construct(), ilObjCategory\__construct(), ilObjFile\__construct(), ilObjSCORM2004LearningModule\__construct(), ilObjSurvey\__construct(), ilObjFileGUI\__construct(), ilObjMediaPoolGUI\__construct(), ilPageObject\__construct(), ilLTIProviderObjectSettingGUI\__construct(), ilLTIProviderObjectSetting\__construct(), ilTree\__construct(), ilDownloadWorkspaceFolderBackgroundTask\__construct(), ilObjStudyProgramme\__construct(), ilMembershipCronNotificationsData\__construct(), ilCmiXapiStatementsDeleteRequest\__construct(), ilMail\__construct(), ILIAS\User\Profile\Prompt\StartUpStep\__construct(), ILIAS\Mail\Cron\ExpiredOrOrphanedMails\MailDeletionHandler\__construct(), ilQuestionPageParser\__construct(), ilMassMailTaskProcessor\__construct(), ILIAS\MediaObjects\MediaObjectManager\__construct(), ilCOPageHTMLExport\__construct(), ilAdvancedMDRecordParser\__construct(), ilAdvancedMDParser\__construct(), ilPageObjectGUI\__construct(), ilRpcClient\__construct(), ilCategoryXmlParser\__construct(), SurveyQuestion\__construct(), ilPCParagraph\_input2xml(), ilTree\_removeEntry(), ilObjSCORMTracking\_syncReadEvent(), ilObject\applyDidacticTemplate(), ilCourseMembershipGUI\assignMembers(), ilGroupMembershipGUI\assignMembers(), ilLearningSequenceMembershipGUI\assignMembers(), ILIAS\Cron\CLI\StartUp\authenticate(), ilInitialisation\blockedAuthentication(), ilStudyProgrammeDIC\buildDIC(), ILIAS\Test\TestDIC\buildDIC(), ilCmiXapiStatementsReportLinkBuilder\buildPipeline(), ilAuthProviderSaml\buildUserAttributeXml(), ILIAS\User\Profile\VCard\buildVCard(), ilSoapUtils\callNextDependency(), ilSoapUtils\callNextNode(), ilAuthFrontend\checkIp(), ilSoapUtils\cloneDependencies(), ilCourseObjectiveQuestion\cloneDependencies(), ilSoapUtils\cloneNode(), ILIAS\Awareness\User\Collector\collectUsers(), ilLORandomTestQuestionPools\copy(), ilObjectCopyGUI\copyMultipleNonContainer(), ilContainer\create(), ilObjRole\delete(), ilPageObject\delete(), ilObjMediaObject\delete(), ilObjSAHSLearningModule\delete(), ilSCORMItem\delete(), ilMediaItem\determineDuration(), ilAccountRegistrationGUI\distributeMails(), ilLDAPServer\doConnectionCheck(), ilStartUpGUI\doLTIAuthentication(), ilStartUpGUI\doSamlAuthentication(), ilStartUpGUI\doStandardAuthentication(), ilRepositoryGUI\executeCommand(), ilObjSAHSLearningModuleGUI\executeCommand(), ilSCORMPresentationGUI\executeCommand(), ilSAHSEditGUI\executeCommand(), ilSCORMPresentationGUI\explorer(), ilNestedSetTree\fetchPredecessorNode(), ilObjCmiXapiGUI\fetchXapiStatements(), ilChatroomServerConnector\file_get_contents(), ilLuceneSearchResultFilter\filter(), ilLTIPlatform\fromConsumerKey(), ilLTIPlatform\fromRecordId(), SeqTreeBuilder\getADLSEQObjectives(), ILIAS\Skill\Usage\SkillUsageManager\getAllUsagesOfTemplate(), ilNestedSetTree\getChildSequenceNumber(), ilSCORM13PlayerGUI\getDebugValues(), ilObjMediaObject\getExternalMetadata(), ilObjSCORMInitData\getIliasScormVars(), ILIAS\Awareness\User\ProviderCurrentCourse\getInitialUserSet(), ilObjLTIConsumer\getLogger(), ilSCORM13PlayerGUI\getNodeData(), SeqTreeBuilder\getObjectives(), ilExAssignment\getPendingFeedbackNotifications(), ilObjectPlugin\getPluginObjectByType(), ilObjSurvey\getSurveysWithTutorResults(), ilInitialisation\goToLogin(), ilInitialisation\handleAuthenticationFail(), ilAuthFrontend\handleAuthenticationSuccess(), ilCourseReferenceAppEventListener\handleEvent(), ilLTIAppEventListener\handleEvent(), ilLTIAppEventListener\handleOutcomeWithoutLP(), ilWebLinkXmlParser\handlerEndTag(), ilAuthProviderSaml\handleSamlAuth(), ilLuceneSearcher\highlight(), ilSCORM13Package\il_import(), ilSoapUtils\ilClone(), ilSoapUtils\ilCloneDependencies(), ilAuthProviderSaml\importUser(), ilContainerImporter\init(), ilObjectCopyGUI\init(), ilLearningModuleImporter\init(), ilStyleImporter\init(), ilSurveyImporter\init(), ilWikiExporter\init(), ilWebDAVDIC\init(), ilObjectRolePermissionTableGUI\initColumns(), ilDidacticTemplateSettingsGUI\initEditTemplate(), ilAuthFrontendCredentialsLTI\initFromRequest(), ilNestedSetTree\insertNode(), ilAuthProviderLTI\isAuthModeLTI(), ilSoapUtils\linkNode(), ilSoapUserAdministration\login(), ilLTIDataConnector\lookupResourcesForAllUsersSinceDate(), ilNestedSetTree\moveTree(), ilLuceneHighlighterResultParser\parse(), ilRepositoryObjectDetailSearch\performLuceneSearch(), ilObjectSearch\performSearch(), ilLuceneSearcher\performSearch(), ilSCORM13PlayerGUI\postLogEntry(), SurveyQuestion\QTIMaterialToString(), ilObjLTIAdministration\readReleaseObjects(), ilInitialisation\redirectToStartingPage(), ilSCORM13Package\removeCPData(), ilInitialisation\resumeUserSession(), ilCleanCOPageHistoryCronjob\run(), ilExcCronReminders\run(), ilMailCronOrphanedMails\run(), ilLuceneIndexer\run(), ilSkillNotifications\run(), ilSurveyCronNotification\run(), ilMailCronOrphanedMails\saveCustomSettings(), ilMultilingualismGUI\saveLanguages(), ilPermissionGUI\savePermissions(), ilMailLuceneSearcher\search(), ilLPTableBaseGUI\searchObjects(), ilMailMimeTransportBase\send(), ilMailMimeTransportNull\send(), ilMailNotification\sendMail(), ilRbacAdmin\setBlockedStatus(), ilFileXMLParser\setFileContents(), ilSCORM2004StoreData\setGlobalObjectives(), ilMailFormGUI\showForm(), ilStudyProgrammeDIC\specificDicFor(), ilSearchAppEventListener\storeElement(), ilObjSCORMTracking\storeJsApiCmi(), ilPasswordAssistanceGUI\submitAssistanceForm(), ilPasswordAssistanceGUI\submitUsernameAssistanceForm(), ilLDAPUserSynchronisation\sync(), ilObjSCORMTracking\syncGlobalStatus(), ilAuthFrontendCredentialsSoap\tryAuthenticationOnLoginPage(), ilPermissionGUI\unblockRoles(), ilContainer\update(), ilObjCourseReference\update(), ilLuceneIndexer\updateLuceneIndex(), ilObjGroupGUI\updateObject(), ilObjSAHSLearningModuleGUI\uploadObject(), ilLuceneSearchResult\valid(), ilScormAiccDataSet\writeData(), and ilSCORM2004StoreData\writeGObjective().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLoggers()

ilLoggerFactory::getLoggers ( )
protected
Returns
ilComponentLogger[]

Definition at line 165 of file class.ilLoggerFactory.php.

165 : array
166 {
167 return $this->loggers;
168 }

References $loggers.

◆ getRootLogger()

static ilLoggerFactory::getRootLogger ( )
static

The unique root logger has a fixed error level.

Definition at line 98 of file class.ilLoggerFactory.php.

98 : ilLogger
99 {
100 $factory = self::getInstance();
101 return $factory->getComponentLogger(self::ROOT_LOGGER);
102 }

References getInstance().

Referenced by ilAssFileUploadUploadsExporter\createFileUploadCollectionZipFile(), and ilInitialisation\initLog().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSettings()

ilLoggerFactory::getSettings ( )

Definition at line 157 of file class.ilLoggerFactory.php.

158 {
159 return $this->settings;
160 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $settings.

Referenced by __construct(), getComponentLogger(), and initUser().

+ Here is the caller graph for this function:

◆ initUser()

ilLoggerFactory::initUser ( string  $a_login)

Init user specific log options.

Definition at line 108 of file class.ilLoggerFactory.php.

108 : void
109 {
110 if (!$this->getSettings()->isBrowserLogEnabledForUser($a_login)) {
111 return;
112 }
113
114 foreach ($this->loggers as $a_component_id => $logger) {
115 if ($this->isConsoleAvailable()) {
116 $browser_handler = new BrowserConsoleHandler();
117 $browser_handler->setLevel($this->getSettings()->getLevelByComponent($a_component_id));
118 $browser_handler->setFormatter(new ilLineFormatter(static::DEFAULT_FORMAT, 'Y-m-d H:i:s.u', true, true));
119 $logger->getLogger()->pushHandler($browser_handler);
120 }
121 }
122 }

References getSettings(), and isConsoleAvailable().

+ Here is the call graph for this function:

◆ isConsoleAvailable()

ilLoggerFactory::isConsoleAvailable ( )
protected

Check if console handler is available.

Definition at line 127 of file class.ilLoggerFactory.php.

127 : bool
128 {
130 return false;
131 }
132 if (
133 $this->dic->isDependencyAvailable('ctrl') && $this->dic->ctrl()->isAsynch() ||
134 (
135 $this->dic->isDependencyAvailable('http') &&
136 strtolower($this->dic->http()->request()->getServerParams()['HTTP_X_REQUESTED_WITH'] ?? '') === 'xmlhttprequest'
137 )
138 ) {
139 return false;
140 }
141
142 if (
143 $this->dic->isDependencyAvailable('http') &&
144 strpos($this->dic->http()->request()->getServerParams()['HTTP_ACCEPT'], 'text/html') !== false
145 ) {
146 return true;
147 }
148 if (
149 $this->dic->isDependencyAvailable('http') &&
150 strpos($this->dic->http()->request()->getServerParams()['HTTP_ACCEPT'], 'application/json') !== false
151 ) {
152 return false;
153 }
154 return true;
155 }
const CONTEXT_WEB
static getType()
Get context type.

References ilContext\CONTEXT_WEB, and ilContext\getType().

Referenced by getComponentLogger(), and initUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isLoggingEnabled()

ilLoggerFactory::isLoggingEnabled ( )

Definition at line 80 of file class.ilLoggerFactory.php.

80 : bool
81 {
82 return $this->enabled;
83 }

References $enabled.

Referenced by getComponentLogger().

+ Here is the caller graph for this function:

◆ newInstance()

static ilLoggerFactory::newInstance ( ilLoggingSettings  $settings)
static

Definition at line 75 of file class.ilLoggerFactory.php.

76 {
77 return static::$instance = new self($settings);
78 }

References $settings.

Field Documentation

◆ $dic

Container ilLoggerFactory::$dic
protected

Definition at line 48 of file class.ilLoggerFactory.php.

◆ $enabled

bool ilLoggerFactory::$enabled = false
private

Definition at line 50 of file class.ilLoggerFactory.php.

Referenced by isLoggingEnabled().

◆ $instance

ilLoggerFactory ilLoggerFactory::$instance = null
staticprivate

Definition at line 45 of file class.ilLoggerFactory.php.

◆ $loggers

array ilLoggerFactory::$loggers = array()
private

Definition at line 55 of file class.ilLoggerFactory.php.

Referenced by getLoggers().

◆ $settings

ilLoggingSettings ilLoggerFactory::$settings
private

Definition at line 47 of file class.ilLoggerFactory.php.

Referenced by __construct(), getInstance(), getSettings(), and newInstance().

◆ COMPONENT_ROOT

const ilLoggerFactory::COMPONENT_ROOT = 'log_root'
protected

Definition at line 42 of file class.ilLoggerFactory.php.

◆ DEFAULT_FORMAT

const ilLoggerFactory::DEFAULT_FORMAT = "[%extra.suid%] [%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"
protected

Definition at line 39 of file class.ilLoggerFactory.php.

◆ ROOT_LOGGER

const ilLoggerFactory::ROOT_LOGGER = 'root'
protected

Definition at line 41 of file class.ilLoggerFactory.php.

◆ SETUP_LOGGER

const ilLoggerFactory::SETUP_LOGGER = 'setup'
protected

Definition at line 43 of file class.ilLoggerFactory.php.


The documentation for this class was generated from the following file: