Usage - Stefanius67/XLogger GitHub Wiki
Steps to create and use your prefered logger
- Create the logger that generates your preferred output.
- Set the output file with proper extension.
For loggers, that creates an output file, you have to specify the filename or full path and the appropriate extension.
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.
See XLogger::setFullpath for available placeholders.
- Set the level for which you want to log.
Look at XLogger::setLogLevel to see, how XLogger treats the log-level
- Set further option, what you want to log.
See XLogger::setOptions for the options supported by the XLogger.
- Set the name of the user, if you want it to be logged.
By default, the XLogger try to read the current $_SERVER["REMOTE_USER"]
. If you use any other user authentication,
just set your current user, if you have enabled logging of the username.
- Pass the logger to your module.
This module should implements LoggerAwareInterface ore use LoggerAwareTrait (Or that at least give any possibility to pass an PSR-3 LoggerInterface)
// 1. Create the logger that generates your prefered output
$logger = new FileLogger();
$logger = new XMLLogger();
$logger = new FirePHPLogger();
$logger = new ChromePHPLogger();
// 2. Set output file with proper extension (if needed...)
$logger->setFullpath('mylog_{date}.xxx');
// 3. Set the level for which you want to log ()
$logger->setLogLevel(LogLevel::EMERGENCY);
// 4. Set further option, what you want to log
$logger->setOptions(XLogger::LOG_BT | XLogger::LOG_USER);
// 5. Set name of user, if you it to be logged
$logger->setUser('SKien');
// 6. pass the logger to the module (that implements LoggerAwareInterface ore use LoggerAwareTrait)
$myModule->setLogger($logger)