ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 = "[%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.

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

58  {
59  global $DIC;
60 
61  $this->dic = $DIC;
62  $this->settings = $settings;
63  $this->enabled = $this->getSettings()->isEnabled();
64  }
global $DIC
Definition: feed.php:28
ilLoggingSettings $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.

References CLIENT_ID, ilLogLevel\DEBUG, getSettings(), isConsoleAvailable(), and isLoggingEnabled().

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 
192  if (!$this->isLoggingEnabled()) {
193  $null_handler = new NullHandler();
194  $logger->pushHandler($null_handler);
195 
196  return $this->loggers[$a_component_id] = new ilComponentLogger($logger);
197  }
198 
199 
200  // standard stream handler
201  $stream_handler = new StreamHandler(
202  $this->getSettings()->getLogDir() . '/' . $this->getSettings()->getLogFile(),
203  Logger::DEBUG, // default minimum level, will be overwritten by component log level
204  true
205  );
206 
207  if ($a_component_id == self::ROOT_LOGGER) {
208  $stream_handler->setLevel($this->getSettings()->getLevelByComponent(self::COMPONENT_ROOT));
209  } else {
210  $stream_handler->setLevel($this->getSettings()->getLevelByComponent($a_component_id));
211  }
212 
213  // format lines
214  $line_formatter = new ilLineFormatter(static::DEFAULT_FORMAT, 'Y-m-d H:i:s.u', true, true);
215  $stream_handler->setFormatter($line_formatter);
216 
217  if ($this->getSettings()->isCacheEnabled()) {
218  // add new finger crossed handler
219  $finger_crossed_handler = new FingersCrossedHandler(
220  $stream_handler,
221  new ErrorLevelActivationStrategy($this->getSettings()->getCacheLevel()),
222  1000
223  );
224  $logger->pushHandler($finger_crossed_handler);
225  } else {
226  $logger->pushHandler($stream_handler);
227  }
228 
229  if (
230  $this->dic->offsetExists('ilUser') &&
231  $this->dic->user() instanceof ilObjUser
232  ) {
233  if ($this->getSettings()->isBrowserLogEnabledForUser($this->dic->user()->getLogin())) {
234  if ($this->isConsoleAvailable()) {
235  $browser_handler = new BrowserConsoleHandler();
236  $browser_handler->setLevel($this->getSettings()->getLevel());
237  $browser_handler->setFormatter($line_formatter);
238  $logger->pushHandler($browser_handler);
239  }
240  }
241  }
242 
243 
244  // suid log
245  $logger->pushProcessor(function ($record) {
246  $record['suid'] = substr(session_id(), 0, 5);
247  return $record;
248  });
249 
250  // append trace
251  $logger->pushProcessor(new ilTraceProcessor(ilLogLevel::DEBUG));
252 
253 
254  // register new logger
255  $this->loggers[$a_component_id] = new ilComponentLogger($logger);
256 
257  return $this->loggers[$a_component_id];
258  }
Component logger with individual log levels by component id.
isConsoleAvailable()
Check if console handler is available.
const CLIENT_ID
Definition: constants.php:41
Custom line formatter.
+ Here is the call graph for this function:

◆ getInstance()

static ilLoggerFactory::getInstance ( )
static

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

References ilLoggingDBSettings\getInstance().

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

67  {
68  if (!static::$instance instanceof ilLoggerFactory) {
70  static::$instance = new ilLoggerFactory($settings);
71  }
72  return static::$instance;
73  }
ilLoggingSettings $settings
+ 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.

References $factory.

Referenced by ilBookCronNotification\__construct(), ilFSWebStorageExercise\__construct(), ilObjCategory\__construct(), ILIAS\COPage\Editor\Components\Paragraph\ParagraphResponseFactory\__construct(), ilUserRoleStartingPointTableGUI\__construct(), SurveyCategories\__construct(), ilWikiDataSet\__construct(), ilImportMapping\__construct(), ilSurveySkill\__construct(), ilExPeerReview\__construct(), ilMailAddressTypeFactory\__construct(), ilCollectWorkspaceFilesJob\__construct(), ilGlossaryTermPermission\__construct(), ilContainerXmlParser\__construct(), ilUserStartingPointGUI\__construct(), ilObjLoggingSettingsGUI\__construct(), ilLTIAppEventListener\__construct(), ilCategoryXmlParser\__construct(), ilGlossaryDataSet\__construct(), ilCheckSumOfWorkspaceFileSizesJob\__construct(), ilMediaObjectDataSet\__construct(), ilMassMailTaskProcessor\__construct(), ilCopyWorkspaceFilesToTempDirectoryJob\__construct(), ilCronFinishUnfinishedTestPasses\__construct(), ilRepoStandardUploadHandlerGUI\__construct(), ilObjWorkspaceFolderGUI\__construct(), ILIAS\COPage\Editor\Server\Server\__construct(), ilObjSurveyQuestionPoolGUI\__construct(), ilLTIProviderObjectSetting\__construct(), ilWikiUserHTMLExport\__construct(), ilXapiResultsCronjob\__construct(), ilDownloadWorkspaceFolderBackgroundTask\__construct(), ilLearningModuleDataSet\__construct(), ilPageContent\__construct(), ilObjSCORM2004LearningModule\__construct(), ilLTIDataConnector\__construct(), ilGlossaryTermGUI\__construct(), SurveyQuestionGUI\__construct(), ilObjGlossaryGUI\__construct(), ilAdvancedMDParser\__construct(), ILIAS\Mail\Cron\ExpiredOrOrphanedMails\MailDeletionHandler\__construct(), ilRpcClient\__construct(), ilObjWikiGUI\__construct(), ilPDStudyProgrammeSimpleListGUI\__construct(), ILIAS\LearningModule\Export\LMHtmlExport\__construct(), ilSurveyPageEditGUI\__construct(), SurveyQuestion\__construct(), ilObjMediaPoolGUI\__construct(), ilExAssignmentReminder\__construct(), ILIAS\Wiki\Export\WikiHtmlExport\__construct(), ilSurveyExecutionGUI\__construct(), ilRbacReview\__construct(), ilCOPageHTMLExport\__construct(), ilStartUpGUI\__construct(), ilSurveyEvaluationGUI\__construct(), ilAppEventHandler\__construct(), ilMail\__construct(), ilMembershipCronNotificationsData\__construct(), ilDataSet\__construct(), ilLTIViewGUI\__construct(), ilAdvancedMDRecordParser\__construct(), ilObjUserFolderGUI\__construct(), ilAccess\__construct(), ilLTITool\__construct(), ilObjFileGUI\__construct(), ilPageContentGUI\__construct(), ilStyleDataSet\__construct(), ilObjStudyProgramme\__construct(), ilLTIProviderObjectSettingGUI\__construct(), ilMDBase\__construct(), ilPageEditorGUI\__construct(), ilObjectCopyGUI\__construct(), ilObject\__construct(), ilQuestionPageParser\__construct(), ilNoteGUI\__construct(), ilPageObject\__construct(), ilExAssignment\__construct(), ilTree\__construct(), ilObjSurvey\__construct(), ilPageObjectGUI\__construct(), ilStartUpGUI\_checkGoto(), ilContainer\_exportContainerSettings(), ilObjUser\_getUsersOnline(), ilPCParagraph\_input2xml(), ilObject\_prepareCloneSelection(), ilTree\_removeEntry(), ilObjMediaObject\_saveUsage(), ilObjSCORMTracking\_syncReadEvent(), ilLPStatus\_updateStatus(), ilContainer\_writeContainerSetting(), ilObject\applyDidacticTemplate(), ilGroupMembershipGUI\assignMembers(), ilLearningSequenceMembershipGUI\assignMembers(), ilCourseMembershipGUI\assignMembers(), ilCronStartUp\authenticate(), ilWebDAVAuthentication\authenticate(), ilInitialisation\blockedAuthentication(), ilStudyProgrammeDIC\buildDIC(), ilCmiXapiStatementsReportLinkBuilder\buildPipeline(), ilObjCmiXapiGUI\buildReportFilter(), ilAuthProviderSaml\buildUserAttributeXml(), ilvCard\buildVCard(), ilSoapUtils\callNextDependency(), ilSoapUtils\callNextNode(), ilAuthFrontend\checkIp(), ilContainer\cloneAllObject(), ilCourseObjectiveQuestion\cloneDependencies(), ilSoapUtils\cloneDependencies(), ilSoapUtils\cloneNode(), ilContainerSorting\cloneSorting(), ilWikiUtil\collectInternalLinks(), ILIAS\Awareness\User\Collector\collectUsers(), ilLORandomTestQuestionPools\copy(), ilQuestionPageParser\copyMobFiles(), ilObjectCopyGUI\copyMultipleNonContainer(), ilContainer\create(), ilObjMediaObject\delete(), ilObjRole\delete(), ilSCORMItem\delete(), ilObjSAHSLearningModule\delete(), ilPageObject\delete(), ilPCMediaObject\deleteHistoryLowerEqualThan(), ilAccountRegistrationGUI\distributeMails(), ilLDAPServer\doConnectionCheck(), ilStartUpGUI\doLTIAuthentication(), ilStartUpGUI\doSamlAuthentication(), ilStartUpGUI\doStandardAuthentication(), ilExSubmission\downloadAllAssignmentFiles(), ilUserProfileStartUpStep\execute(), ilObjSAHSLearningModuleGUI\executeCommand(), ilSCORMPresentationGUI\executeCommand(), ilSAHSEditGUI\executeCommand(), ilRepositoryGUI\executeCommand(), ilSCORMPresentationGUI\explorer(), ilObjCmiXapiGUI\fetchXapiStatements(), ilChatroomServerConnector\file_get_contents(), ilLuceneSearchResultFilter\filter(), ilLTIPlatform\fromConsumerKey(), ilLTIPlatform\fromRecordId(), SeqTreeBuilder\getADLSEQObjectives(), ilSkillUsage\getAllUsagesOfTemplate(), ilSCORM13PlayerGUI\getDebugValues(), ilObjSCORMInitData\getIliasScormVars(), ILIAS\Awareness\User\ProviderCurrentCourse\getInitialUserSet(), ilObjLTIConsumer\getLogger(), ilSCORM13PlayerGUI\getNodeData(), ilNotification\getNotificationsForObject(), SeqTreeBuilder\getObjectives(), ilObjectPlugin\getPluginObjectByType(), ilObjSurvey\getSurveysWithTutorResults(), ilInitialisation\goToLogin(), ilInitialisation\handleAuthenticationFail(), ilAuthFrontend\handleAuthenticationSuccess(), ilCourseReferenceAppEventListener\handleEvent(), ilLTIAppEventListener\handleEvent(), ilLTIAppEventListener\handleOutcomeWithoutLP(), ilSurveySkill\handleQuestionDeletion(), ilWebLinkXmlParser\handlerEndTag(), ilAuthProviderSaml\handleSamlAuth(), ilLuceneSearcher\highlight(), ilSCORM13Package\il_import(), ilSoapUtils\ilClone(), ilSoapUtils\ilCloneDependencies(), ilAuthProviderSaml\importUser(), ilContainerImporter\init(), ilWikiExporter\init(), ilStyleImporter\init(), ilLearningModuleImporter\init(), ilSurveyImporter\init(), ilObjectCopyGUI\init(), ilObjectRolePermissionTableGUI\initColumns(), ilDidacticTemplateSettingsGUI\initEditTemplate(), ilAuthFrontendCredentialsLTI\initFromRequest(), ilRbacAdmin\initIntersectionPermissions(), ilNestedSetTree\insertNode(), ilTree\insertNodeFromTrash(), ilRepUtil\insertSavedNodes(), ilAuthProviderLTI\isAuthModeLTI(), ilUserProfile\isProfileIncomplete(), ilSoapUtils\linkNode(), ilSoapUserAdministration\login(), ilLTIDataConnector\lookupResourcesForAllUsersSinceDate(), ilLTIDataConnector\lookupResourcesForUserObjectRelation(), ilMDRights\lookupRightsByTypeAndCopyright(), ilPCResources\modifyItemGroupRefIdsByMapping(), ilNestedSetTree\moveTree(), ilLuceneHighlighterResultParser\parse(), ilAdministrationSettingsFormHandler\parseFieldValue(), ilRepositoryObjectDetailSearch\performLuceneSearch(), ilObjectSearch\performSearch(), ilLuceneSearcher\performSearch(), ilSCORM2004StoreData\persistCMIData(), ilSCORM13PlayerGUI\postLogEntry(), SurveyQuestion\QTIMaterialToString(), ilLPStatus\raiseEvent(), ilObjLTIAdministration\readReleaseObjects(), ilInitialisation\redirectToStartingPage(), ilSCORM13Package\removeCPData(), ilInitialisation\resumeUserSession(), ilLuceneIndexer\run(), ilSurveyCronNotification\run(), ilExcCronReminders\run(), ilCleanCOPageHistoryCronjob\run(), ilSkillNotifications\run(), ilMailCronOrphanedMails\run(), ilMailCronOrphanedMails\saveCustomSettings(), ilMultilingualismGUI\saveLanguages(), ilPCMediaObject\saveMobUsage(), ilPermissionGUI\savePermissions(), ilMailLuceneSearcher\search(), ilLPTableBaseGUI\searchObjects(), ilMailMimeTransportNull\send(), ilMailMimeTransportBase\send(), ilMailNotification\sendMail(), ilWikiUtil\sendNotification(), ilExAssignmentReminder\sentReminderPlaceholders(), ilObjSurvey\sentReminderPlaceholders(), ilRbacAdmin\setBlockedStatus(), ilSCORM2004StoreData\setCMIData(), ilFileXMLParser\setFileContents(), ilSCORM2004StoreData\setGlobalObjectives(), ilUserProfileStartUpStep\shouldInterceptRequest(), ilMailFormGUI\showForm(), ilStudyProgrammeDIC\specificDicFor(), ilSearchAppEventListener\storeElement(), ilObjSCORMTracking\storeJsApiCmi(), ilPasswordAssistanceGUI\submitAssistanceForm(), ilPasswordAssistanceGUI\submitUsernameAssistanceForm(), ilLDAPUserSynchronisation\sync(), ilObjSCORMTracking\syncGlobalStatus(), ilAuthFrontendCredentialsSoap\tryAuthenticationOnLoginPage(), ilPermissionGUI\unblockRoles(), ilObjCourseReference\update(), ilContainer\update(), ilLuceneIndexer\updateLuceneIndex(), ilObjGroupGUI\updateObject(), ilExAssignment\uploadAssignmentFiles(), ilObjSAHSLearningModuleGUI\uploadObject(), ilLuceneSearchResult\valid(), ilScormAiccDataSet\writeData(), and ilSCORM2004StoreData\writeGObjective().

89  : ilLogger
90  {
91  $factory = self::getInstance();
92  return $factory->getComponentLogger($a_component_id);
93  }
$factory
Definition: metadata.php:75
+ Here is the caller graph for this function:

◆ getLoggers()

ilLoggerFactory::getLoggers ( )
protected
Returns
ilComponentLogger[]

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

References $loggers.

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

◆ getRootLogger()

static ilLoggerFactory::getRootLogger ( )
static

The unique root logger has a fixed error level.

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

References $factory.

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

98  : ilLogger
99  {
100  $factory = self::getInstance();
101  return $factory->getComponentLogger(self::ROOT_LOGGER);
102  }
$factory
Definition: metadata.php:75
+ Here is the caller graph for this function:

◆ getSettings()

ilLoggerFactory::getSettings ( )

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

References $settings.

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

158  {
159  return $this->settings;
160  }
ilLoggingSettings $settings
+ 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.

References getSettings(), and isConsoleAvailable().

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  }
isConsoleAvailable()
Check if console handler is available.
Custom line formatter.
+ 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.

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

Referenced by getComponentLogger(), and initUser().

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.
+ 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.

References $enabled.

Referenced by getComponentLogger().

80  : bool
81  {
82  return $this->enabled;
83  }
+ Here is the caller graph for this function:

◆ newInstance()

static ilLoggerFactory::newInstance ( ilLoggingSettings  $settings)
static

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

References $settings.

76  {
77  return static::$instance = new self($settings);
78  }
ilLoggingSettings $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(), 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 = "[%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: