ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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.

43 {
44 $this->settings = $settings;
45 $this->enabled = $this->getSettings()->isEnabled();
46
47 }
getSettings()
Get settigns.

References $settings, and getSettings().

+ 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
\Logger

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

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 }
Handler sending logs to browser's javascript console with no browser extension required.
Buffers all records until a certain level is reached.
Stores to any stream resource.
Monolog log channel.
Definition: Logger.php:28
Component logger with individual log levels by component id.
Custom line formatter.
isConsoleAvailable()
Check if console handler is available.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276

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

+ Here is the call graph for this function:

◆ getInstance()

static ilLoggerFactory::getInstance ( )
static
Returns
ilLoggerFactory

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

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 }
static getInstance()
Get instance.

References $settings, and ilLoggingDBSettings\getInstance().

Referenced by ilCourseAppEventListener\__construct(), ilGroupAppEventListener\__construct(), ilRbacAdmin\assignUser(), ilRbacAdmin\deassignUser(), getLogger(), getRootLogger(), ilCourseAppEventListener\handleUserAssignments(), ilGroupAppEventListener\handleUserAssignments(), and ilParticipant\updateMemberRoles().

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

83 {
84 $factory = self::getInstance();
85 return $factory->getComponentLogger($a_component_id);
86 }

References getInstance().

Referenced by ilObjLoggingSettingsGUI\__construct(), ilCOPageHTMLExport\__construct(), ilAdvancedMDRecordParser\__construct(), ilObjFile\__construct(), ilObjFileGUI\__construct(), ilAdvancedMDParser\__construct(), ilObjectCopyGUI\__construct(), ilAuthContainerLDAP\__construct(), ilImport\__construct(), ilWikiHTMLExport\__construct(), ilGlossaryDataSet\__construct(), ilPDStudyProgrammeSimpleListGUI\__construct(), ilWikiDataSet\__construct(), ilDataSet\__construct(), ilStyleDataSet\__construct(), ilLDAPQuery\__construct(), ilWikiUserHTMLExport\__construct(), ilAuthUtils\_getAuthModeOfUser(), ilAuthUtils\_initAuth(), ilDidacticTemplateLocalRoleAction\apply(), ilRbacAdmin\assignRoleToFolder(), ilInitialisation\authenticate(), ilSearchGUI\autoComplete(), ilvCard\buildVCard(), ilObjLinkResourceGUI\callLink(), ilSoapUtils\callNextDependency(), ilSoapUtils\callNextNode(), ilContainer\cloneAllObject(), ilObjGroup\cloneAutoGeneratedRoles(), ilCourseObjectiveQuestion\cloneDependencies(), ilSoapUtils\cloneDependencies(), ilSoapUtils\cloneNode(), ilObjGroup\cloneObject(), ilAwarenessUserCollector\collectUsers(), ilDidacticTemplateGUI\confirmTemplateSwitch(), ilLORandomTestQuestionPools\copy(), ilObjectCopyGUI\copyContainer(), ilObjectCopyGUI\copyContainerToTargets(), ilObjectCopyGUI\copyMultipleNonContainer(), ilDidacticTemplateLocalPolicyAction\createLocalPolicy(), ilObjRole\delete(), ilPageObject\delete(), ilObjMediaObject\delete(), ilDidacticTemplateBlockRoleAction\deleteLocalPolicy(), ilMail\distributeMail(), ilLDAPServer\doConnectionCheck(), ilObjRoleFolderGUI\doRemoveRolePermissions(), ilRepositoryGUI\executeCommand(), ilMail\explodeRecipients(), ilAuthBase\failedLoginObserver(), ilAuthContainerMultiple\fetchData(), ilAuthContainerMDB2\fetchData(), ilChatroomServerConnector\file_get_contents(), ilLogComponentTableGUI\fillRow(), ilObjectRolePermissionTableGUI\fillRow(), ilLuceneSearchResultFilter\filter(), ilDidacticTemplateAction\filterRoles(), ilSkillUsage\getAllUsagesOfTemplate(), ilAuthModeDetermination\getAuthModeSequence(), ilPluginsOverviewTableGUI\getComponents(), ilLuceneAdvancedSearchFields\getFormElement(), ilAwarenessUserProviderCurrentCourse\getInitialUserSet(), ilAwarenessUserProviderMemberships\getInitialUserSet(), ilMail\getUserIds(), ilAuthContainerApache\handleLDAPDataSource(), ilWebLinkXmlParser\handlerEndTag(), ilLuceneSearcher\highlight(), ilCourseObjective\ilClone(), ilSoapUtils\ilClone(), ilSoapUtils\ilCloneDependencies(), ilContObjParser\ilContObjParser(), ilLuceneFileSearch\ilLuceneFileSearch(), ilObjContentObject\ilObjContentObject(), ilObjWikiGUI\ilObjWikiGUI(), ilPageContentGUI\ilPageContentGUI(), ilPageEditorGUI\ilPageEditorGUI(), ilPageObject\ilPageObject(), ilPageObjectGUI\ilPageObjectGUI(), ilDidacticTemplateSettingsGUI\importTemplate(), ilLearningModuleImporter\init(), ilWikiExporter\init(), ilCOPageImporter\init(), ilObjectCopyGUI\init(), ilStyleImporter\init(), ilAuthBase\initAuth(), ilObjectRolePermissionTableGUI\initColumns(), ilTree\insertNodeFromTrash(), ilRepUtil\insertSavedNodes(), ilSoapUtils\linkNode(), ilAuthBase\loginObserver(), ilAuthBase\logoutObserver(), ilStartUpGUI\migrateAccount(), ilAuthLogObserver\notify(), ilLogComponentTableGUI\parse(), ilRepositoryObjectDetailSearch\performLuceneSearch(), ilObjectSearch\performSearch(), ilLuceneSearcher\performSearch(), ilMailCronOrphanedMailsDeletionProcessor\processDeletion(), ilSystemCheckTrash\readSelectedDeleted(), ilLDAPUserSynchronisation\readUserData(), ilObjSearchSettingsGUI\refreshLuceneSettings(), ilMail\replacePlaceholders(), ilDidacticTemplateLocalPolicyAction\revertLocalPolicy(), ilObjLoggingSettingsGUI\saveComponentLevels(), ilPermissionGUI\savePermissions(), ilLPTableBaseGUI\searchObjects(), ilMail\sendMail(), ilMailNotification\sendMail(), ilRbacAdmin\setBlockedStatus(), ilFileXMLParser\setFileContents(), ilQueryParser\setMinWordLength(), ilObjectCopyGUI\showItemSelection(), ilSearchAppEventListener\storeElement(), ilLDAPUserSynchronisation\sync(), ilPermissionGUI\unblockRoles(), ilLogComponentLevel\update(), ilLuceneIndexer\updateLuceneIndex(), ilObjectCopyGUI\updateProgress(), ilDidacticTemplateExcludeFilterPattern\valid(), ilDidacticTemplateIncludeFilterPattern\valid(), ilLuceneSearchResult\valid(), ilMaterializedPathTree\validateParentRelations(), and ilNestedSetTree\validateParentRelations().

+ 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 156 of file class.ilLoggerFactory.php.

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

References $loggers.

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

93 {
94 $factory = self::getInstance();
95 return $factory->getComponentLogger(self::ROOT_LOGGER);
96 }

References getInstance().

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

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

◆ getSettings()

ilLoggerFactory::getSettings ( )

Get settigns.

Returns
ilLoggingSettings

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

148 {
149 return $this->settings;
150 }

References $settings.

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

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

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 }

References getSettings(), and isConsoleAvailable().

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

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.

References $_GET, 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:

◆ newInstance()

static ilLoggerFactory::newInstance ( ilLoggingSettings  $settings)
static

get new instance

Parameters
ilLoggingSettings$settings
Returns
\self

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

70 {
71 return new self($settings);
72 }

References $settings.

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: