ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

This class supplies an implementation for the locator. The locator will send its output to ist own frame, enabling more flexibility in the design of the desktop.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilLoggerFactory::__construct ( ilLoggingSettings  $settings)
protected

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

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

42  {
43  $this->settings = $settings;
44  $this->enabled = $this->getSettings()->isEnabled();
45  }
getSettings()
Get settigns.
settings()
Definition: settings.php:2
+ 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 158 of file class.ilLoggerFactory.php.

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

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

◆ getInstance()

static ilLoggerFactory::getInstance ( )
static
Returns
ilLoggerFactory

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

References $settings, and ilLoggingDBSettings\getInstance().

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

52  {
53  if (!static::$instance) {
54  include_once './Services/Logging/classes/class.ilLoggingDBSettings.php';
56  static::$instance = new ilLoggerFactory($settings);
57  }
58  return static::$instance;
59  }
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 79 of file class.ilLoggerFactory.php.

References $factory.

Referenced by ilRpcClient\__call(), ilAuthProviderFactory\__construct(), ilCalendarScheduleFilterExercise\__construct(), ilAuthFrontendCredentials\__construct(), ilFSWebStorageExercise\__construct(), ilUserRoleStartingPointTableGUI\__construct(), ilUserStartingPointGUI\__construct(), ilMediaObjectDataSet\__construct(), ilImportMapping\__construct(), ilZipBackgroundTaskHandler\__construct(), ilAuthProvider\__construct(), ilStartUpGUI\__construct(), ilGlossaryDataSet\__construct(), ilWikiDataSet\__construct(), ilAuthFrontend\__construct(), ilMailCronOrphanedMailsDeletionProcessor\__construct(), ilObjUserFolderGUI\__construct(), ilExport\__construct(), ilSurveySkill\__construct(), ilAwarenessUserProvider\__construct(), ilAuthStatus\__construct(), ilImport\__construct(), ilLearningModuleDataSet\__construct(), ilObjFileGUI\__construct(), ilAuthFrontendFactory\__construct(), ilObjLoggingSettingsGUI\__construct(), ilStyleDataSet\__construct(), ilSoapClient\__construct(), ilAdvancedMDParser\__construct(), ilGlossaryTermPermission\__construct(), ilContainerXmlParser\__construct(), ilBackgroundTask\__construct(), ilSCORM2004Item\__construct(), ilLOEditorGUI\__construct(), ilWikiHTMLExport\__construct(), ilRpcClient\__construct(), ilObjWikiGUI\__construct(), ilWikiUserHTMLExport\__construct(), ilDataSet\__construct(), ilRbacReview\__construct(), ilPageContent\__construct(), ilObjSurveyGUI\__construct(), ilCOPageHTMLExport\__construct(), ilMembershipGUI\__construct(), ilGlossaryTermGUI\__construct(), ilPDStudyProgrammeSimpleListGUI\__construct(), SurveyCategories\__construct(), ilPageContentGUI\__construct(), ilObjContentObject\__construct(), ilSurveyEvaluationGUI\__construct(), ilAdvancedMDRecordParser\__construct(), ilCategoryXmlParser\__construct(), ilObjSurveyQuestionPoolGUI\__construct(), ilMDSaxParser\__construct(), ilMDBase\__construct(), ilSurveyPageGUI\__construct(), ilPageEditorGUI\__construct(), ilSurveyExecutionGUI\__construct(), SurveyQuestionGUI\__construct(), ilObjFile\__construct(), ilExAssignment\__construct(), ilAccess\__construct(), ilContObjParser\__construct(), ilContainerContentGUI\__construct(), ilObjGlossaryGUI\__construct(), ilObjectCopyGUI\__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(), ilDidacticTemplateLocalRoleAction\apply(), ilObject\applyDidacticTemplate(), ilGroupMembershipGUI\assignMembers(), ilCourseMembershipGUI\assignMembers(), ilRbacAdmin\assignRoleToFolder(), ilCronStartUp\authenticate(), ilWebDAVAuthentication\authenticate(), ilInitialisation\authenticate(), ilSearchGUI\autoComplete(), ilInitialisation\blockedAuthentication(), ilvCard\buildVCard(), ilObjLinkResourceGUI\callLink(), ilSoapUtils\callNextDependency(), ilSoapUtils\callNextNode(), ilCaptchaUtil\checkFreetype(), ilAuthFrontend\checkIp(), ilContainer\cloneAllObject(), ilObjGroup\cloneAutoGeneratedRoles(), ilCourseObjectiveQuestion\cloneDependencies(), ilSoapUtils\cloneDependencies(), ilSoapUtils\cloneNode(), ilContainerSorting\cloneSorting(), ilAwarenessUserCollector\collectUsers(), ilDidacticTemplateGUI\confirmTemplateSwitch(), ilLORandomTestQuestionPools\copy(), ilObjectCopyGUI\copyContainer(), ilObjectCopyGUI\copyContainerToTargets(), ilContObjParser\copyMobFiles(), ilObjectCopyGUI\copyMultipleNonContainer(), ilRbacAdmin\copyRolePermissionIntersection(), ilContainer\create(), ilDidacticTemplateLocalPolicyAction\createLocalPolicy(), ilObjMediaObject\delete(), ilObjRole\delete(), ilPageObject\delete(), ilDidacticTemplateBlockRoleAction\deleteLocalPolicy(), ilMail\distributeMail(), ilStartUpGUI\doApacheAuthentication(), ilLDAPServer\doConnectionCheck(), ilStartUpGUI\doLTIAuthentication(), ilObjRoleFolderGUI\doRemoveRolePermissions(), ilStartUpGUI\doSamlAuthentication(), ilStartUpGUI\doShibbolethAuthentication(), ilStartUpGUI\doStandardAuthentication(), ilRepositoryGUI\executeCommand(), ilAuthBase\failedLoginObserver(), ilChatroomServerConnector\file_get_contents(), ilLogComponentTableGUI\fillRow(), ilLuceneSearchResultFilter\filter(), ilDidacticTemplateAction\filterRoles(), ilAuthContainerApache\forceCreation(), 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(), ilAuthContainerApache\handleLDAPDataSource(), 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(), ilParticipantTableGUI\initFilter(), ilRbacAdmin\initIntersectionPermissions(), ilNestedSetTree\insertNode(), ilMaterializedPathTree\insertNode(), ilTree\insertNodeFromTrash(), ilRepUtil\insertSavedNodes(), ilAuthProviderLTI\isAuthModeLTI(), ilUserProfile\isProfileIncomplete(), ilMailLoginOrEmailAddressAddressType\isValid(), ilMailMailingListAddressType\isValid(), ilSoapUtils\linkNode(), ilObjectPlugin\loadRepoPlugin(), ilAuthBase\loginObserver(), ilAuthBase\logoutObserver(), ilCalendarSchedule\modifyEventByFilters(), ilMaterializedPathTree\moveTree(), ilNestedSetTree\moveTree(), ilAuthLogObserver\notify(), ilLogComponentTableGUI\parse(), ilLuceneHighlighterResultParser\parse(), ilMail\parseAddresses(), ilMembershipGUI\participantsResetFilter(), 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(), ilMailGroupAddressType\resolve(), ilMailLoginOrEmailAddressAddressType\resolve(), ilMailMailingListAddressType\resolve(), ilMailRoleAddressType\resolve(), ilInitialisation\resumeUserSession(), ilDidacticTemplateLocalPolicyAction\revertLocalPolicy(), ilMembershipCronNotifications\run(), ilLuceneIndexer\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(), ilMail\sendMail(), ilObjSurvey\sentReminderPlaceholders(), ilRbacAdmin\setBlockedStatus(), ilFileXMLParser\setFileContents(), ilQueryParser\setMinWordLength(), ilRepositorySearchGUI\showClipboard(), ilMailFormGUI\showForm(), ilObjectCopyGUI\showItemSelection(), ilSearchAppEventListener\storeElement(), ilContainerBlockPropertiesStorage\storeProperty(), ilDidacticTemplateUtils\switchTemplate(), ilLDAPUserSynchronisation\sync(), ilDAVServer\tryAuthentication(), ilPermissionGUI\unblockRoles(), ilLogComponentLevel\update(), ilContainer\update(), ilLuceneIndexer\updateLuceneIndex(), ilParticipant\updateMemberRoles(), ilClient\updateNIC(), ilObjGroupGUI\updateObject(), ilObjectCopyGUI\updateProgress(), ilExAssignment\uploadAssignmentFiles(), ilDidacticTemplateExcludeFilterPattern\valid(), ilDidacticTemplateIncludeFilterPattern\valid(), ilLuceneSearchResult\valid(), ilMaterializedPathTree\validateParentRelations(), ilNestedSetTree\validateParentRelations(), and ilLPStatus\writeStatus().

80  {
81  $factory = self::getInstance();
82  return $factory->getComponentLogger($a_component_id);
83  }
$factory
Definition: metadata.php:47
+ Here is the caller graph for this function:

◆ getLoggers()

ilLoggerFactory::getLoggers ( )
protected
Returns
ilComponentLogger[]

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

References $loggers.

149  {
150  return $this->loggers;
151  }

◆ getRootLogger()

static ilLoggerFactory::getRootLogger ( )
static

The unique root logger has a fixed error level.

Returns
ilLogger

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

References $factory.

Referenced by ilAssFileUploadUploadsExporter\createFileUploadCollectionZipFile(), ilCalendarFileHandler\downloadFilesForEvents(), ilCalendarInboxGUI\executeCommand(), ilInitialisation\initLog(), and assFlashQuestion\saveAdditionalQuestionDataToDb().

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

◆ getSettings()

ilLoggerFactory::getSettings ( )

Get settigns.

Returns
ilLoggingSettings

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

References $settings.

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

140  {
141  return $this->settings;
142  }
+ 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 101 of file class.ilLoggerFactory.php.

References getSettings(), and isConsoleAvailable().

102  {
103  if (!$this->getSettings()->isBrowserLogEnabledForUser($a_login)) {
104  return true;
105  }
106 
107  include_once("./Services/Logging/classes/extensions/class.ilLineFormatter.php");
108 
109  foreach ($this->loggers as $a_component_id => $logger) {
110  if ($this->isConsoleAvailable()) {
111  $browser_handler = new BrowserConsoleHandler();
112  $browser_handler->setLevel($this->getSettings()->getLevelByComponent($a_component_id));
113  $browser_handler->setFormatter(new ilLineFormatter(static::DEFAULT_FORMAT, 'Y-m-d H:i:s.u', true, true));
114  $logger->getLogger()->pushHandler($browser_handler);
115  }
116  }
117  }
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 123 of file class.ilLoggerFactory.php.

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

Referenced by getComponentLogger(), and initUser().

124  {
125  include_once './Services/Context/classes/class.ilContext.php';
127  return false;
128  }
129  if (isset($_GET["cmdMode"]) && $_GET["cmdMode"] == "asynch") {
130  return false;
131  }
132  return true;
133  }
$_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 66 of file class.ilLoggerFactory.php.

References $settings.

67  {
68  return static::$instance = new self($settings);
69  }

Field Documentation

◆ $enabled

ilLoggerFactory::$enabled = false
private

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

◆ $instance

ilLoggerFactory::$instance = null
staticprivate

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

◆ $loggers

ilLoggerFactory::$loggers = array()
private

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

Referenced by getLoggers().

◆ $settings

ilLoggerFactory::$settings = null
private

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

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

◆ COMPONENT_ROOT

const ilLoggerFactory::COMPONENT_ROOT = 'log_root'

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

◆ DEFAULT_FORMAT

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

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

◆ ROOT_LOGGER

const ilLoggerFactory::ROOT_LOGGER = 'root'

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

◆ SETUP_LOGGER

const ilLoggerFactory::SETUP_LOGGER = 'setup'

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


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