-
Notifications
You must be signed in to change notification settings - Fork 7
Logging
David Pauli edited this page Aug 26, 2016
·
2 revisions
To log problems or errors you can use the internal Logger object. This is used in a static way.
Its easy to configure the Logger via config.json. For more information about Configuration look into the wiki section.
{
"logging":
{
"level": "NOTIFICATION",
"output": "SCREEN",
"outputfile": null
}
}| level | description | since |
|---|---|---|
| NOTIFICATION | Log all messages, also notifications. This is only recommended on development. | 0.0.0 |
| WARNING | Only log warnings and errors. | 0.0.0 |
| ERROR | Only log errors. | 0.0.0 |
| NONE | Don't log anything. | 0.0.0 |
| output | description | since |
|---|---|---|
| SCREEN | Show log messages directly on screen. *This is not recommended in live mode! | 0.0.0 |
| FILE | Print all log messages into a file. This file needs to set via outputfile json attribute. | 0.1.2 |
Its also possible to initialize the Logger object direct in PHP.
ep6\Logger::setLogLevel(ep6\LogLevel::NOTIFICATION);
ep6\Logger::setOutput(ep6\LogOutput::SCREEN);
ep6\Logger::setOutputFile("/tmp/ep6.log");Its also easy to use this Logger also in your own code.
ep6\Logger::notify("Hi I am a notification.");
ep6\Logger::warning("This is a warning message.");
ep6\Logger::error("ERROR");
// Forcing a log message will print this message EVERYTIME. It doesn't matter if you mute the Logger via LogLevel.
ep6\Logger::force("This message is logged everytime.");A log message everytime has the IP which causes this error and the happen date / time.
1.2.3.4 - [26/Aug/2016:14:48:54 +0200]
<THE MESSAGE TO LOG>
Error and warning messages also will print a stacktrace automatically after the log message.