ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilLoggerFactory Class Reference

Logging factory. More...

+ Collaboration diagram for ilLoggerFactory:

Public Member Functions

 initUser ($a_login)
 Init user specific log options. More...
 
 getSettings ()
 Get settigns. More...
 
 getComponentLogger ($a_component_id)
 Get component logger. More...
 

Static Public Member Functions

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

Data Fields

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'
 

Protected Member Functions

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

Private Attributes

 $settings = null
 
 $enabled = false
 
 $loggers = array()
 

Static Private Attributes

static $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 21 of file class.ilLoggerFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ilLoggerFactory::__construct ( ilLoggingSettings  $settings)
protected

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

References $settings, getSettings(), and settings().

37  {
38  $this->settings = $settings;
39  $this->enabled = $this->getSettings()->isEnabled();
40  }
settings()
Definition: settings.php:2
getSettings()
Get settigns.
+ Here is the call graph for this function:

Member Function Documentation

◆ getComponentLogger()

ilLoggerFactory::getComponentLogger (   $a_component_id)

Get component logger.

Parameters
type$a_component_id
Returns

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

References $GLOBALS, ilLogLevel\DEBUG, getSettings(), isConsoleAvailable(), and user().

154  {
155  if (isset($this->loggers[$a_component_id])) {
156  return $this->loggers[$a_component_id];
157  }
158 
159  $loggerNamePrefix = '';
160  if (defined('CLIENT_ID')) {
161  $loggerNamePrefix = CLIENT_ID . '_';
162  }
163 
164  switch ($a_component_id) {
165  case 'root':
166  $logger = new Logger($loggerNamePrefix . 'root');
167  break;
168 
169  default:
170  $logger = new Logger($loggerNamePrefix . $a_component_id);
171  break;
172 
173  }
174 
175  if (!$this->getSettings()->isEnabled()) {
176  $null_handler = new NullHandler();
177  $logger->pushHandler($null_handler);
178 
179  include_once './Services/Logging/classes/class.ilComponentLogger.php';
180  return $this->loggers[$a_component_id] = new ilComponentLogger($logger);
181  }
182 
183 
184  // standard stream handler
185  $stream_handler = new StreamHandler(
186  $this->getSettings()->getLogDir() . '/' . $this->getSettings()->getLogFile(),
187  true
188  );
189 
190  if ($a_component_id == self::ROOT_LOGGER) {
191  $stream_handler->setLevel($this->getSettings()->getLevelByComponent(self::COMPONENT_ROOT));
192  } else {
193  $stream_handler->setLevel($this->getSettings()->getLevelByComponent($a_component_id));
194  }
195 
196  // format lines
197  include_once("./Services/Logging/classes/extensions/class.ilLineFormatter.php");
198  $line_formatter = new ilLineFormatter(static::DEFAULT_FORMAT, 'Y-m-d H:i:s.u', true, true);
199  $stream_handler->setFormatter($line_formatter);
200 
201  if ($this->getSettings()->isCacheEnabled()) {
202  // add new finger crossed handler
203  $finger_crossed_handler = new FingersCrossedHandler(
204  $stream_handler,
205  new ErrorLevelActivationStrategy($this->getSettings()->getCacheLevel()),
206  1000
207  );
208  $logger->pushHandler($finger_crossed_handler);
209  } else {
210  $logger->pushHandler($stream_handler);
211  }
212 
213  if (
214  $GLOBALS['DIC']->offsetExists('ilUser') &&
215  $GLOBALS['DIC']['ilUser'] instanceof ilObjUser
216  ) {
217  if ($this->getSettings()->isBrowserLogEnabledForUser($GLOBALS['DIC']->user()->getLogin())) {
218  if ($this->isConsoleAvailable()) {
219  $browser_handler = new BrowserConsoleHandler();
220  #$browser_handler->setLevel($this->getSettings()->getLevelByComponent($a_component_id));
221  $browser_handler->setLevel($this->getSettings()->getLevel());
222  $browser_handler->setFormatter($line_formatter);
223  $logger->pushHandler($browser_handler);
224  }
225  }
226  }
227 
228 
229  // suid log
230  $logger->pushProcessor(function ($record) {
231  $record['suid'] = substr(session_id(), 0, 5);
232  return $record;
233  });
234 
235  // append trace
236  include_once './Services/Logging/classes/extensions/class.ilTraceProcessor.php';
237  $logger->pushProcessor(new ilTraceProcessor(ilLogLevel::DEBUG));
238 
239 
240  // register new logger
241  include_once './Services/Logging/classes/class.ilComponentLogger.php';
242  $this->loggers[$a_component_id] = new ilComponentLogger($logger);
243 
244  return $this->loggers[$a_component_id];
245  }
Buffers all records until a certain level is reached.
getSettings()
Get settigns.
Monolog log channel.
Definition: Logger.php:28
Component logger with individual log levels by component id.
Handler sending logs to browser's javascript console with no browser extension required.
user()
Definition: user.php:4
isConsoleAvailable()
Check if console handler is available.
Custom line formatter.
Stores to any stream resource.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:

◆ getInstance()

static ilLoggerFactory::getInstance ( )
static
Returns
ilLoggerFactory

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

References $settings, and ilLoggingDBSettings\getInstance().

Referenced by ilGroupAppEventListener\__construct(), ilOpenIdConnectAppEventListener\__construct(), ilCourseAppEventListener\__construct(), ilRbacAdmin\assignUser(), ilRbacAdmin\deassignUser(), ilGroupAppEventListener\handleUserAssignments(), ilCourseAppEventListener\handleUserAssignments(), ilInitialisation\initILIAS(), and ilInitialisation\initStyle().

47  {
48  if (!static::$instance) {
49  include_once './Services/Logging/classes/class.ilLoggingDBSettings.php';
51  static::$instance = new ilLoggerFactory($settings);
52  }
53  return static::$instance;
54  }
Logging factory.
static getInstance()
Get instance.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLogger()

static ilLoggerFactory::getLogger (   $a_component_id)
static

Get component logger.

See also
mudules.xml or service.xml
Parameters
string$a_component_id
Returns
ilLogger

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

References $factory.

Referenced by ilRpcClient\__call(), ilAuthProviderFactory\__construct(), ilFSWebStorageExercise\__construct(), ilAuthFrontendCredentials\__construct(), ilUserRoleStartingPointTableGUI\__construct(), ilUserStartingPointGUI\__construct(), ilImportMapping\__construct(), ilMediaObjectDataSet\__construct(), ilZipBackgroundTaskHandler\__construct(), ilAuthProvider\__construct(), ilMailCronOrphanedMailsDeletionProcessor\__construct(), ilAuthFrontend\__construct(), ilGlossaryDataSet\__construct(), ilObjUserFolderGUI\__construct(), ilWikiDataSet\__construct(), ilExport\__construct(), ilCalendarScheduleFilterTimings\__construct(), ilAwarenessUserProvider\__construct(), ilSurveySkill\__construct(), ilImport\__construct(), ilAuthStatus\__construct(), ilBookCronNotification\__construct(), ilLearningModuleDataSet\__construct(), ilObjFileGUI\__construct(), ilAuthFrontendFactory\__construct(), ilExAssignmentReminder\__construct(), ilObjLoggingSettingsGUI\__construct(), ilAdvancedMDParser\__construct(), ilMailAddressTypeFactory\__construct(), ilStyleDataSet\__construct(), ilSoapClient\__construct(), ilGlossaryTermPermission\__construct(), ilContainerXmlParser\__construct(), ilStartUpGUI\__construct(), ilBackgroundTask\__construct(), ilSCORM2004Item\__construct(), ilWikiHTMLExport\__construct(), ilRpcClient\__construct(), ilRbacReview\__construct(), ilDataSet\__construct(), ilObjWikiGUI\__construct(), ilWikiUserHTMLExport\__construct(), ilObjSurveyGUI\__construct(), ilPageContent\__construct(), ilCOPageHTMLExport\__construct(), ilPDStudyProgrammeSimpleListGUI\__construct(), ilGlossaryTermGUI\__construct(), ilMembershipCronNotificationsData\__construct(), SurveyCategories\__construct(), ilPageContentGUI\__construct(), ilObjContentObject\__construct(), ilObjMediaPoolGUI\__construct(), ilSurveyEvaluationGUI\__construct(), ilAdvancedMDRecordParser\__construct(), ilCategoryXmlParser\__construct(), ilMDSaxParser\__construct(), ilObjSurveyQuestionPoolGUI\__construct(), ilMDBase\__construct(), ilSurveyPageGUI\__construct(), ilPageEditorGUI\__construct(), ilAppEventHandler\__construct(), ilSurveyExecutionGUI\__construct(), SurveyQuestionGUI\__construct(), ilAccess\__construct(), ilContObjParser\__construct(), ilObjFile\__construct(), ilObjGlossaryGUI\__construct(), ilContainerContentGUI\__construct(), ilObjectCopyGUI\__construct(), ilExAssignment\__construct(), ilPageObjectGUI\__construct(), ilPageObject\__construct(), ilTree\__construct(), SurveyQuestion\__construct(), ilObjSurvey\__construct(), ilAccountRegistrationGUI\__distributeMails(), ilLinkChecker\__validateLinks(), ilStartUpGUI\_checkGoto(), ilAuthUtils\_getAuthModeOfUser(), ilObject\_prepareCloneSelection(), ilTree\_removeEntry(), ilLPStatus\_updateStatus(), ilContainer\_writeContainerSetting(), ilObjUser\_writeHistory(), ilCalendarScheduleFilterTimings\addCustomEvents(), ilUserProfileIncompleteRequestTargetAdjustmentCase\adjust(), ilDidacticTemplateLocalRoleAction\apply(), ilObject\applyDidacticTemplate(), ilGroupMembershipGUI\assignMembers(), ilCourseMembershipGUI\assignMembers(), ilLearningSequenceMembershipGUI\assignMembers(), ilRbacAdmin\assignRoleToFolder(), ilCronStartUp\authenticate(), ilWebDAVAuthentication\authenticate(), ilInitialisation\authenticate(), ilSearchGUI\autoComplete(), ilInitialisation\blockedAuthentication(), ilvCard\buildVCard(), ilObjLinkResourceGUI\callLink(), ilSoapUtils\callNextDependency(), ilSoapUtils\callNextNode(), ilObjFileDAV\checkForVirus(), ilCaptchaUtil\checkFreetype(), ilAuthFrontend\checkIp(), ilContainer\cloneAllObject(), ilObjGroup\cloneAutoGeneratedRoles(), ilCourseObjectiveQuestion\cloneDependencies(), ilSoapUtils\cloneDependencies(), ilObjGroup\cloneDependencies(), ilObjCourse\cloneDependencies(), ilSoapUtils\cloneNode(), ilContainerSorting\cloneSorting(), ilAwarenessUserCollector\collectUsers(), ilDidacticTemplateGUI\confirmTemplateSwitch(), ilLORandomTestQuestionPools\copy(), ilObjectCopyGUI\copyContainer(), ilObjectCopyGUI\copyContainerToTargets(), ilContObjParser\copyMobFiles(), ilObjectCopyGUI\copyMultipleNonContainer(), ilRbacAdmin\copyRolePermissionIntersection(), ilContainer\create(), ilObjContainerDAV\createDirectory(), ilDidacticTemplateLocalPolicyAction\createLocalPolicy(), ilObjMediaObject\delete(), ilObjRole\delete(), ilPageObject\delete(), ilDidacticTemplateBlockRoleAction\deleteLocalPolicy(), ilMail\distributeMail(), ilStartUpGUI\doApacheAuthentication(), ilLDAPServer\doConnectionCheck(), IMSGlobal\LTI\ToolProvider\ResourceLink\doLTI11Service(), ilStartUpGUI\doLTIAuthentication(), ilStartUpGUI\doOpenIdConnectAuthentication(), ilObjRoleFolderGUI\doRemoveRolePermissions(), ilStartUpGUI\doSamlAuthentication(), IMSGlobal\LTI\ToolProvider\ResourceLink\doService(), ilStartUpGUI\doShibbolethAuthentication(), ilStartUpGUI\doStandardAuthentication(), ilRepositoryGUI\executeCommand(), ilAuthBase\failedLoginObserver(), ilChatroomServerConnector\file_get_contents(), ilObjFileDAV\fileUploadWithStream(), ilLogComponentTableGUI\fillRow(), ilLuceneSearchResultFilter\filter(), ilDidacticTemplateAction\filterRoles(), ilLTIToolConsumer\fromRecordId(), ilMembershipNotifications\getActiveUsersforAllObjects(), ilSkillUsage\getAllUsagesOfTemplate(), ilAuthModeDetermination\getAuthModeSequence(), ilLuceneAdvancedSearchFields\getFormElement(), ilAttendanceList\getHTML(), ilAwarenessUserProviderCurrentCourse\getInitialUserSet(), ilContainerBlockPropertiesStorage\getProperty(), ilMaterializedPathTree\getRelation(), ilNestedSetTree\getRelation(), ilRbacReview\getRolesOfRoleFolder(), ilNestedSetTree\getSubtreeInfo(), ilInitialisation\goToLogin(), ilAuthFrontend\handleAuthenticationSuccess(), ilOpenIdConnectAppEventListener\handleEvent(), ilObjFileDAV\handleFileUpload(), ilWebLinkXmlParser\handlerEndTag(), ilAuthProviderSaml\handleSamlAuth(), ilLuceneSearcher\highlight(), ilCourseObjective\ilClone(), ilSoapUtils\ilClone(), ilSoapUtils\ilCloneDependencies(), ilDidacticTemplateSettingsGUI\importTemplate(), ilAuthProviderSaml\importUser(), ilStyleImporter\init(), ilContainerImporter\init(), ilLearningModuleImporter\init(), ilWikiExporter\init(), ilSurveyImporter\init(), ilObjectCopyGUI\init(), ilAuthBase\initAuth(), ilObjectRolePermissionTableGUI\initColumns(), ilDidacticTemplateSettingsGUI\initEditTemplate(), ilRbacAdmin\initIntersectionPermissions(), ilNestedSetTree\insertNode(), ilMaterializedPathTree\insertNode(), ilTree\insertNodeFromTrash(), ilRepUtil\insertSavedNodes(), ilAuthProviderLTI\isAuthModeLTI(), ilUserProfile\isProfileIncomplete(), ilSoapUtils\linkNode(), ilObjectPlugin\loadOrgUnitPlugin(), ilObjectPlugin\loadRepoPlugin(), ilSoapUserAdministration\login(), ilAuthBase\loginObserver(), ilAuthBase\logoutObserver(), ilMDRights\lookupRightsByTypeAndCopyright(), ilMaterializedPathTree\moveTree(), ilNestedSetTree\moveTree(), ilAuthLogObserver\notify(), ilLogComponentTableGUI\parse(), ilLuceneHighlighterResultParser\parse(), ilMail\parseAddresses(), ilRepositoryObjectDetailSearch\performLuceneSearch(), ilObjectSearch\performSearch(), ilLuceneSearcher\performSearch(), ilMailCronOrphanedMailsDeletionProcessor\processDeletion(), SurveyQuestion\QTIMaterialToString(), ilLPStatus\raiseEvent(), ilAttendanceList\readOrderedExportableFields(), ilObjLTIAdministration\readReleaseObjects(), ilSystemCheckTrash\readSelectedDeleted(), ilLDAPUserSynchronisation\readUserData(), ilWaitingListTableGUI\readUserData(), ilInitialisation\redirect(), ilObjSearchSettingsGUI\refreshLuceneSettings(), ilMail\replacePlaceholders(), ilInitialisation\resumeUserSession(), ilDidacticTemplateLocalPolicyAction\revertLocalPolicy(), ilLuceneIndexer\run(), ilExcCronReminders\run(), ilSkillNotifications\run(), ilMailCronOrphanedMails\run(), ilObjLoggingSettingsGUI\saveComponentLevels(), ilMailCronOrphanedMails\saveCustomSettings(), ilMultilingualismGUI\saveLanguages(), ilPermissionGUI\savePermissions(), ilMailLuceneSearcher\search(), ilLPTableBaseGUI\searchObjects(), ilMailMimeTransportNull\send(), ilMailMimeTransportBase\send(), IMSGlobal\LTI\HTTPMessage\send(), ilMailNotification\sendMail(), ilMembershipCronNotifications\sendMail(), ilMail\sendMail(), ilExAssignmentReminder\sentReminderPlaceholders(), ilObjSurvey\sentReminderPlaceholders(), ilRbacAdmin\setBlockedStatus(), ilFileXMLParser\setFileContents(), ilQueryParser\setMinWordLength(), ilUserProfileIncompleteRequestTargetAdjustmentCase\shouldAdjustRequest(), ilRepositorySearchGUI\showClipboard(), ilMailFormGUI\showForm(), ilObjectCopyGUI\showItemSelection(), ilSearchAppEventListener\storeElement(), ilContainerBlockPropertiesStorage\storeProperty(), ilPasswordAssistanceGUI\submitAssistanceForm(), ilPasswordAssistanceGUI\submitUsernameAssistanceForm(), ilDidacticTemplateUtils\switchTemplate(), ilLDAPUserSynchronisation\sync(), ilAuthFrontendCredentialsSoap\tryAuthenticationOnLoginPage(), ilPermissionGUI\unblockRoles(), ilLogComponentLevel\update(), ilContainer\update(), ilLuceneIndexer\updateLuceneIndex(), ilClient\updateNIC(), ilObjGroupGUI\updateObject(), ilGroupMembershipGUI\updateParticipantsStatus(), ilObjectCopyGUI\updateProgress(), ilMDEditorGUI\updateQuickEdit(), ilExAssignment\uploadAssignmentFiles(), ilDidacticTemplateExcludeFilterPattern\valid(), ilDidacticTemplateIncludeFilterPattern\valid(), ilLuceneSearchResult\valid(), ilMaterializedPathTree\validateParentRelations(), ilNestedSetTree\validateParentRelations(), and ilLPStatus\writeStatus().

75  {
76  $factory = self::getInstance();
77  return $factory->getComponentLogger($a_component_id);
78  }
$factory
Definition: metadata.php:43
+ Here is the caller graph for this function:

◆ getLoggers()

ilLoggerFactory::getLoggers ( )
protected
Returns
ilComponentLogger[]

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

References $loggers.

144  {
145  return $this->loggers;
146  }

◆ getRootLogger()

static ilLoggerFactory::getRootLogger ( )
static

The unique root logger has a fixed error level.

Returns
ilLogger

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

References $factory.

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

85  {
86  $factory = self::getInstance();
87  return $factory->getComponentLogger(self::ROOT_LOGGER);
88  }
$factory
Definition: metadata.php:43
+ Here is the caller graph for this function:

◆ getSettings()

ilLoggerFactory::getSettings ( )

Get settigns.

Returns
ilLoggingSettings

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

References $settings.

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

135  {
136  return $this->settings;
137  }
+ Here is the caller graph for this function:

◆ initUser()

ilLoggerFactory::initUser (   $a_login)

Init user specific log options.

Parameters
type$a_login
Returns
boolean

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

References getSettings(), and isConsoleAvailable().

97  {
98  if (!$this->getSettings()->isBrowserLogEnabledForUser($a_login)) {
99  return true;
100  }
101 
102  include_once("./Services/Logging/classes/extensions/class.ilLineFormatter.php");
103 
104  foreach ($this->loggers as $a_component_id => $logger) {
105  if ($this->isConsoleAvailable()) {
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);
110  }
111  }
112  }
getSettings()
Get settigns.
Handler sending logs to browser's javascript console with no browser extension required.
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.

Returns
boolean

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

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

Referenced by getComponentLogger(), and initUser().

119  {
120  include_once './Services/Context/classes/class.ilContext.php';
122  return false;
123  }
124  if (isset($_GET["cmdMode"]) && $_GET["cmdMode"] == "asynch") {
125  return false;
126  }
127  return true;
128  }
$_GET["client_id"]
const CONTEXT_WEB
static getType()
Get context type.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ newInstance()

static ilLoggerFactory::newInstance ( ilLoggingSettings  $settings)
static

get new instance

Parameters
ilLoggingSettings$settings
Returns

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

References $settings.

62  {
63  return static::$instance = new self($settings);
64  }

Field Documentation

◆ $enabled

ilLoggerFactory::$enabled = false
private

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

◆ $instance

ilLoggerFactory::$instance = null
staticprivate

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

◆ $loggers

ilLoggerFactory::$loggers = array()
private

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

Referenced by getLoggers().

◆ $settings

ilLoggerFactory::$settings = null
private

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

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

◆ COMPONENT_ROOT

const ilLoggerFactory::COMPONENT_ROOT = 'log_root'

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

◆ DEFAULT_FORMAT

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

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

◆ ROOT_LOGGER

const ilLoggerFactory::ROOT_LOGGER = 'root'

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

◆ SETUP_LOGGER

const ilLoggerFactory::SETUP_LOGGER = 'setup'

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


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