Class FirePHPLogger - Stefanius67/XLogger GitHub Wiki
Full name: \SKien\XLogger\FirePHPLogger
Parent class: \SKien\XLogger\XLogger
PSR-3 compliant logger for Output to the FirePHP console of the browser.
This class does not use all of FirePHP's capabilities, but can be used very flexibly due to the PSR-3 compatibility - also for logging existing components into the browser console.
Method | Description |
---|---|
__construct | Init logging level and remote username (if set). |
alert | Action must be taken immediately. |
critical | Critical conditions. |
debug | Detailed debug information. |
emergency | System is unusable. |
error | Runtime errors that do not require immediate action but should typically be logged and monitored. |
getFilename | Get current filename (may be some placeholders are supplemented). |
getFullpath | Get full path of the logfile. |
info | Interesting events. |
log | Logs with an arbitrary level. |
notice | Normal but significant events. |
setFilename | Set the filename for the logfile. |
setFullpath | Set the path and filename for the logfile. |
setLogLevel | Set the level from witch items should be logged. |
setOptions | Set Options for logging. |
setPath | Set the path for the logfile. |
setUser | Set the username. |
warning | Exceptional occurrences that are not errors. |
Init logging level and remote username (if set).
public FirePHPLogger::__construct(string $level = LogLevel::DEBUG)
Parameters:
Parameter | Type | Description |
---|---|---|
level |
string | the min. LogLevel to be logged |
See Also:
Logs with an arbitrary level.
public FirePHPLogger::log(string $level, mixed $message, array $context = array()) : void
Parameters:
Parameter | Type | Description |
---|---|---|
level |
string | |
message |
mixed | |
context |
array |
Action must be taken immediately.
public AbstractLogger::alert(string $message, array $context = array()) : void
Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.
Parameters:
Parameter | Type | Description |
---|---|---|
message |
string | |
context |
array |
Critical conditions.
public AbstractLogger::critical(string $message, array $context = array()) : void
Example: Application component unavailable, unexpected exception.
Parameters:
Parameter | Type | Description |
---|---|---|
message |
string | |
context |
array |
Detailed debug information.
public AbstractLogger::debug(string $message, array $context = array()) : void
Parameters:
Parameter | Type | Description |
---|---|---|
message |
string | |
context |
array |
System is unusable.
public AbstractLogger::emergency(string $message, array $context = array()) : void
Parameters:
Parameter | Type | Description |
---|---|---|
message |
string | |
context |
array |
Runtime errors that do not require immediate action but should typically be logged and monitored.
public AbstractLogger::error(string $message, array $context = array()) : void
Parameters:
Parameter | Type | Description |
---|---|---|
message |
string | |
context |
array |
Get current filename (may be some placeholders are supplemented).
public XLogger::getFilename() : string
Return Type: string
See Also:
Get full path of the logfile.
public XLogger::getFullpath() : string
Return Type: string
See Also:
Interesting events.
public AbstractLogger::info(string $message, array $context = array()) : void
Example: User logs in, SQL logs.
Parameters:
Parameter | Type | Description |
---|---|---|
message |
string | |
context |
array |
Normal but significant events.
public AbstractLogger::notice(string $message, array $context = array()) : void
Parameters:
Parameter | Type | Description |
---|---|---|
message |
string | |
context |
array |
Set the filename for the logfile.
public XLogger::setFilename(string $strFilename) : void
Some placeholders can be used for date/month/year/week.
Parameters:
Parameter | Type | Description |
---|---|---|
strFilename |
string |
See Also:
Set the path and filename for the logfile.
public XLogger::setFullpath(string $strFullpath) : void
In order to be able to assign logfiles chronologically and / or to a user, it is
possible to use placeholders in the file name or path, which are replaced accordingly
before the file is created.
Following placeholders are supported:
- {date} : will be replaced by current date (Format 'YYYY-MM-DD')
- {month} : will be replaced by current month (Format 'YYYY-MM')
- {year} : will be replaced by current year (Format 'YYYY')
- {week} : will be replaced by current ISO-8601 week (Format 'YYYY_WW')
- {name} : will be replaced by the username
Note:
If you use the placeholder for the user name, this have to be set BEFORE the call of this method. In the username, all characters except A-Z, a-z, 0-9, '_' and '-' are filtered out (to always get a valid file name)!
Parameters:
Parameter | Type | Description |
---|---|---|
strFullpath |
string |
Set the level from witch items should be logged.
public XLogger::setLogLevel(string $strLogLevel) : void
All entries with a lower level than the specified are ignored.
The relevance of the defined PSR-3 level from hight to low are:
- EMERGENCY
- ALERT
- CRITICAL
- ERROR
- WARNING
- NOTICE
- INFO
- DEBUG
Parameters:
Parameter | Type | Description |
---|---|---|
strLogLevel |
string | the min. LogLevel to be logged |
Set Options for logging.
public XLogger::setOptions(int $iOptions) : void
Use any combination of:
- XLogger::LOG_IP : include IP-adress in log item
- XLogger::LOG_BT : include backtrace 'filename (line)' in log item
- XLogger::LOG_USER : include user in log item
- XLogger::LOG_UA : include user-agent in log item
Parameters:
Parameter | Type | Description |
---|---|---|
iOptions |
int | any combination (bitwise or, '|') of the flags described |
Set the path for the logfile.
public XLogger::setPath(string $strPath) : void
Some placeholders can be used for date/month/year/week.
Parameters:
Parameter | Type | Description |
---|---|---|
strPath |
string |
See Also:
Set the username.
public XLogger::setUser(string $strUser) : void
Parameters:
Parameter | Type | Description |
---|---|---|
strUser |
string |
Exceptional occurrences that are not errors.
public AbstractLogger::warning(string $message, array $context = array()) : void
Example: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.
Parameters:
Parameter | Type | Description |
---|---|---|
message |
string | |
context |
array |