ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 27 of file class.ilLoggerFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ilLoggerFactory::__construct ( ilLoggingSettings  $settings)
protected

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

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

43  {
44  $this->settings = $settings;
45  $this->enabled = $this->getSettings()->isEnabled();
46 
47  }
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 166 of file class.ilLoggerFactory.php.

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

167  {
168  if(isset($this->loggers[$a_component_id]))
169  {
170  return $this->loggers[$a_component_id];
171  }
172 
173  switch($a_component_id)
174  {
175  case 'root':
176  $logger = new Logger(CLIENT_ID.'_root');
177  break;
178 
179  default:
180  $logger = new Logger(CLIENT_ID.'_'.$a_component_id);
181  break;
182 
183  }
184 
185  if(!$this->getSettings()->isEnabled())
186  {
187  $null_handler = new NullHandler();
188  $logger->pushHandler($null_handler);
189 
190  include_once './Services/Logging/classes/class.ilComponentLogger.php';
191  return $this->loggers[$a_component_id] = new ilComponentLogger($logger);
192  }
193 
194 
195  // standard stream handler
196  $stream_handler = new StreamHandler(
197  $this->getSettings()->getLogDir().'/'.$this->getSettings()->getLogFile(),
198  TRUE
199  );
200 
201  if($a_component_id == self::ROOT_LOGGER)
202  {
203  $stream_handler->setLevel($this->getSettings()->getLevelByComponent(self::COMPONENT_ROOT));
204  }
205  else
206  {
207  $stream_handler->setLevel($this->getSettings()->getLevelByComponent($a_component_id));
208  }
209 
210  // format lines
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);
214 
215  if($this->getSettings()->isCacheEnabled())
216  {
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  }
225  else
226  {
227  $logger->pushHandler($stream_handler);
228  }
229 
230  if($GLOBALS['ilUser'] instanceof ilObjUser)
231  {
232  if($this->getSettings()->isBrowserLogEnabledForUser($GLOBALS['ilUser']->getLogin()))
233  {
234  if($this->isConsoleAvailable())
235  {
236  $browser_handler = new BrowserConsoleHandler();
237  #$browser_handler->setLevel($this->getSettings()->getLevelByComponent($a_component_id));
238  $browser_handler->setLevel($this->getSettings()->getLevel());
239  $browser_handler->setFormatter($line_formatter);
240  $logger->pushHandler($browser_handler);
241  }
242  }
243  }
244 
245 
246  // suid log
247  $logger->pushProcessor(function ($record) {
248  $record['suid'] = substr(session_id(),0,5);
249  return $record;
250  });
251 
252  // append trace
253  include_once './Services/Logging/classes/extensions/class.ilTraceProcessor.php';
254  $logger->pushProcessor(new ilTraceProcessor(ilLogLevel::DEBUG));
255 
256 
257  // register new logger
258  include_once './Services/Logging/classes/class.ilComponentLogger.php';
259  $this->loggers[$a_component_id] = new ilComponentLogger($logger);
260 
261  return $this->loggers[$a_component_id];
262  }
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.
+ Here is the call graph for this function:

◆ getInstance()

static ilLoggerFactory::getInstance ( )
static
Returns
ilLoggerFactory

Definition at line 53 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().

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

Referenced by ilRpcClient\__call(), ilAuthProviderFactory\__construct(), ilCalendarScheduleFilterExercise\__construct(), ilMailCronOrphanedMailsDeletionProcessor\__construct(), ilAuthFrontendCredentials\__construct(), ilMailLuceneSearcher\__construct(), ilImportMapping\__construct(), ilSurveySkill\__construct(), ilZipBackgroundTaskHandler\__construct(), ilCOPageHTMLExport\__construct(), ilStartUpGUI\__construct(), ilAuthProvider\__construct(), ilGlossaryDataSet\__construct(), ilWikiHTMLExport\__construct(), ilAuthFrontend\__construct(), ilWikiDataSet\__construct(), ilObjSurveyGUI\__construct(), ilAuthSession\__construct(), ilExport\__construct(), ilObjFileGUI\__construct(), ilAwarenessUserProvider\__construct(), ilAuthStatus\__construct(), ilImport\__construct(), ilLearningModuleDataSet\__construct(), ilContainerXmlParser\__construct(), ilObjFile\__construct(), ilObjWikiGUI\__construct(), ilGlossaryTermGUI\__construct(), ilSurveyEvaluationGUI\__construct(), ilAuthFrontendFactory\__construct(), ilSurveyPageGUI\__construct(), ilObjLoggingSettingsGUI\__construct(), ilStyleDataSet\__construct(), ilSoapClient\__construct(), ilAdvancedMDParser\__construct(), ilDataSet\__construct(), ilGlossaryTermPermission\__construct(), ilSCORM2004Item\__construct(), ilBackgroundTask\__construct(), ilObjContentObject\__construct(), SurveyQuestionGUI\__construct(), ilLOEditorGUI\__construct(), ilRpcClient\__construct(), ilWikiUserHTMLExport\__construct(), ilRbacReview\__construct(), ilPageContent\__construct(), ilMembershipGUI\__construct(), ilPageContentGUI\__construct(), ilPDStudyProgrammeSimpleListGUI\__construct(), ilAuthContainerLDAP\__construct(), ilObjSurveyQuestionPoolGUI\__construct(), SurveyCategories\__construct(), ilSurveyExecutionGUI\__construct(), ilPageEditorGUI\__construct(), ilObjectCopyGUI\__construct(), ilCategoryXmlParser\__construct(), ilAdvancedMDRecordParser\__construct(), ilMDSaxParser\__construct(), ilMDBase\__construct(), ilPageObject\__construct(), ilPageObjectGUI\__construct(), ilContObjParser\__construct(), ilObjGlossaryGUI\__construct(), ilTree\__construct(), SurveyQuestion\__construct(), ilObjSurvey\__construct(), ilLinkChecker\__validateLinks(), ilAuthUtils\_getAuthModeOfUser(), ilAuthUtils\_initAuth(), ilTree\_removeEntry(), ilLPStatus\_updateStatus(), ilContainer\_writeContainerSetting(), ilDidacticTemplateLocalRoleAction\apply(), ilObject\applyDidacticTemplate(), ilGroupMembershipGUI\assignMembers(), ilCourseMembershipGUI\assignMembers(), ilRbacAdmin\assignRoleToFolder(), ilMimeMail\Attach(), ilCronStartUp\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(), ilObjGroup\cloneObject(), ilObject\cloneObject(), ilContainerSorting\cloneSorting(), ilAwarenessUserCollector\collectUsers(), ilDidacticTemplateGUI\confirmTemplateSwitch(), ilLORandomTestQuestionPools\copy(), ilObjectCopyGUI\copyContainer(), ilObjectCopyGUI\copyContainerToTargets(), ilObjectCopyGUI\copyMultipleNonContainer(), ilRbacAdmin\copyRolePermissionIntersection(), ilContainer\create(), ilDidacticTemplateLocalPolicyAction\createLocalPolicy(), ilObjMediaObject\delete(), ilObjRole\delete(), ilPageObject\delete(), ilDidacticTemplateBlockRoleAction\deleteLocalPolicy(), ilMail\distributeMail(), ilStartUpGUI\doApacheAuthentication(), ilLDAPServer\doConnectionCheck(), ilObjRoleFolderGUI\doRemoveRolePermissions(), ilStartUpGUI\doShibbolethAuthentication(), ilStartUpGUI\doStandardAuthentication(), ilRepositoryGUI\executeCommand(), ilAuthBase\failedLoginObserver(), ilAuthContainerMultiple\fetchData(), ilChatroomServerConnector\file_get_contents(), ilLogComponentTableGUI\fillRow(), ilLuceneSearchResultFilter\filter(), ilDidacticTemplateAction\filterRoles(), ilAuthContainerApache\forceCreation(), ilMembershipNotifications\getActiveUsersforAllObjects(), ilSkillUsage\getAllUsagesOfTemplate(), ilAuthModeDetermination\getAuthModeSequence(), ilLuceneAdvancedSearchFields\getFormElement(), ilAwarenessUserProviderCurrentCourse\getInitialUserSet(), ilMaterializedPathTree\getRelation(), ilNestedSetTree\getRelation(), ilMailRoleAddressType\getRoleIdsByAddress(), ilRbacReview\getRolesOfRoleFolder(), ilMail\getSavedData(), ilNestedSetTree\getSubtreeInfo(), ilMailFormGUI\getTemplateDataById(), ilInitialisation\goToLogin(), ilAuthFrontend\handleAuthenticationSuccess(), ilAuthContainerApache\handleLDAPDataSource(), ilWebLinkXmlParser\handlerEndTag(), ilLuceneSearcher\highlight(), ilCourseObjective\ilClone(), ilSoapUtils\ilClone(), ilSoapUtils\ilCloneDependencies(), ilDidacticTemplateSettingsGUI\importTemplate(), ilStyleImporter\init(), ilContainerImporter\init(), ilLearningModuleImporter\init(), ilWikiExporter\init(), ilCOPageImporter\init(), ilSurveyImporter\init(), ilObjectCopyGUI\init(), ilAuthBase\initAuth(), ilObjectRolePermissionTableGUI\initColumns(), ilParticipantTableGUI\initFilter(), ilRbacAdmin\initIntersectionPermissions(), ilNestedSetTree\insertNode(), ilMaterializedPathTree\insertNode(), ilTree\insertNodeFromTrash(), ilRepUtil\insertSavedNodes(), ilUserProfile\isProfileIncomplete(), ilSoapUtils\linkNode(), ilObjectPlugin\loadRepoPlugin(), ilAuthBase\loginObserver(), ilAuthBase\logoutObserver(), ilStartUpGUI\migrateAccount2(), ilCalendarSchedule\modifyEventByFilters(), ilMaterializedPathTree\moveTree(), ilNestedSetTree\moveTree(), ilAuthLogObserver\notify(), ilLogComponentTableGUI\parse(), ilLuceneHighlighterResultParser\parse(), ilMail\parseAddresses(), ilMembershipGUI\parseSubscriberTable(), ilRepositoryObjectDetailSearch\performLuceneSearch(), ilObjectSearch\performSearch(), ilLuceneSearcher\performSearch(), ilMailCronOrphanedMailsDeletionProcessor\processDeletion(), SurveyQuestion\QTIMaterialToString(), ilLPStatus\raiseEvent(), ilAttendanceList\readOrderedExportableFields(), ilSystemCheckTrash\readSelectedDeleted(), ilLDAPUserSynchronisation\readUserData(), ilObjSearchSettingsGUI\refreshLuceneSettings(), ilMail\replacePlaceholders(), ilMailGroupAddressType\resolve(), ilMailLoginOrEmailAddressAddressType\resolve(), ilMailMailingListAddressType\resolve(), ilInitialisation\resumeUserSession(), ilDidacticTemplateLocalPolicyAction\revertLocalPolicy(), ilMembershipCronNotifications\run(), ilLuceneIndexer\run(), ilMailCronOrphanedMails\run(), ilObjLoggingSettingsGUI\saveComponentLevels(), ilMailCronOrphanedMails\saveCustomSettings(), ilMultilingualismGUI\saveLanguages(), ilPermissionGUI\savePermissions(), ilLPTableBaseGUI\searchObjects(), ilMailNotification\sendMail(), ilObjSurvey\sentReminderPlaceholders(), ilRbacAdmin\setBlockedStatus(), ilFileXMLParser\setFileContents(), ilQueryParser\setMinWordLength(), ilRepositorySearchGUI\showClipboard(), ilObjectCopyGUI\showItemSelection(), ilSearchAppEventListener\storeElement(), ilDidacticTemplateUtils\switchTemplate(), ilLDAPUserSynchronisation\sync(), ilDAVServer\tryAuthentication(), ilPermissionGUI\unblockRoles(), ilLogComponentLevel\update(), ilContainer\update(), ilLuceneIndexer\updateLuceneIndex(), ilParticipant\updateMemberRoles(), ilClient\updateNIC(), ilObjGroupGUI\updateObject(), ilObjectCopyGUI\updateProgress(), ilDidacticTemplateExcludeFilterPattern\valid(), ilDidacticTemplateIncludeFilterPattern\valid(), ilLuceneSearchResult\valid(), ilMaterializedPathTree\validateParentRelations(), ilNestedSetTree\validateParentRelations(), and ilLPStatus\writeStatus().

83  {
84  $factory = self::getInstance();
85  return $factory->getComponentLogger($a_component_id);
86  }
+ Here is the caller graph for this function:

◆ getLoggers()

ilLoggerFactory::getLoggers ( )
protected
Returns
ilComponentLogger[]

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

References $loggers.

157  {
158  return $this->loggers;
159  }

◆ getRootLogger()

static ilLoggerFactory::getRootLogger ( )
static

The unique root logger has a fixed error level.

Returns
ilLogger

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

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

93  {
94  $factory = self::getInstance();
95  return $factory->getComponentLogger(self::ROOT_LOGGER);
96  }
+ Here is the caller graph for this function:

◆ getSettings()

ilLoggerFactory::getSettings ( )

Get settigns.

Returns
ilLoggingSettings

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

References $settings.

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

148  {
149  return $this->settings;
150  }
+ 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 104 of file class.ilLoggerFactory.php.

References getSettings(), and isConsoleAvailable().

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

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

Referenced by getComponentLogger(), and initUser().

130  {
131  include_once './Services/Context/classes/class.ilContext.php';
133  {
134  return FALSE;
135  }
136  if (isset($_GET["cmdMode"]) && $_GET["cmdMode"] == "asynch")
137  {
138  return FALSE;
139  }
140  return TRUE;
141  }
$_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 69 of file class.ilLoggerFactory.php.

References $settings.

70  {
71  return static::$instance = new self($settings);
72  }

Field Documentation

◆ $enabled

ilLoggerFactory::$enabled = FALSE
private

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

◆ $instance

ilLoggerFactory::$instance = null
staticprivate

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

◆ $loggers

ilLoggerFactory::$loggers = array()
private

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

Referenced by getLoggers().

◆ $settings

ilLoggerFactory::$settings = null
private

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

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

◆ COMPONENT_ROOT

const ilLoggerFactory::COMPONENT_ROOT = 'log_root'

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

◆ DEFAULT_FORMAT

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

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

◆ ROOT_LOGGER

const ilLoggerFactory::ROOT_LOGGER = 'root'

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

◆ SETUP_LOGGER

const ilLoggerFactory::SETUP_LOGGER = 'setup'

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


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