Provides a handler for Monolog that sends records to piwik server.
This library can be installed via composer: "piotr-cz/monolog-piwik-handler": "~1.0"
$ composer require piotr-cz/monolog-piwik-handler
Example setup using Pimple DI Container
// Add PiwikTracker to DIC
$container['PiwikTracker'] = function($c) {
return new \PiwikTracker(
// idSite
1,
// apiUrl
'http://piwik.domain.tld/'
);
}
// Add Logger to DIC
$container['logger'] = function($c) {
$logger = new \Monolog\Logger('app']);
$logger->pushHandler(
new \PiotrCz\MonologPiwikHandler\PiwikHandler(
// Piwik tracker instance
$c['PiwikTracker'],
// Optional category to log errors to.
'Errors'
)
);
}
Then in your error handler
$logger->addError('500', ['exception' => $exception]);
- PHP 5.3+
Released under the MIT License