|Last Updated|| ||Ratings|| ||Unique User Downloads|| ||Download Rankings|
|2016-11-14 (2 years ago) || 73%||Total: 312 ||All time: 7,110 This week: 414|
This package can log messages and view log filtered files.
It provides a base logger class that is extended by a class that sends log messages to files.
A separate class can list and filter logs from the command line according to given criteria like the log level of each message, log message date and text in the log message.
Prize: One subscription to the PDF edition of the PHP Architect magazine
|Logging actions is an important functionality that many applications implement.
There are many components to implement logging, but this package goes further by providing a means to search and filter logs according to a given criteria of interest like the log level, date or text in the log message.
A simple logger system
You need only to require this package in your project
`composer require jlaso/simple-logger
In order to let know the library where can put its database file and other things related with setup you can copy the distribution file
config-simple-logger.yml.dist in the root of your project with the
This file contains:
In order to check log file you can use
`src/console log:filter [--with=word1,word2,...] [--levels=error,info] [--date-from="2016-01-01 00:00:00"]
Running the example
Go to terminal and start the demo example
error_reporting(E_ALL & !E_WARNING);
use JLaso\SimpleLogger\PlainFileLogger as Logger;
$start = microtime(true);
Logger::info("This is only the start of the program");
'title' => 'This is the title',
'data' => 'more data',
$a = 1234/ $b;
Logger::info('Just finishing the execution of the program in '.intval((microtime(true)-$start)*1000).' msec !');
Implementing the filter command in your app
You can see an example of how to do that (https://github.com/jlaso/simple-stats-demo/tree/master/app)[https://github.com/jlaso/simple-stats-demo/tree/master/app]
class FilterLogCommand extends FilterCommand
add it to app/console
require_once __DIR__ . '/../vendor/autoload.php';
use App\Command\FilterLogCommand; <======
$application = new Application();
new FilterLogCommand(), <======
1.0.3 added date_format in order to have different logs names for every day
||Applications that use this package
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.