Skip to content

piotr-cz/monolog-piwik-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Piwik Handler for Monolog

Provides a handler for Monolog that sends records to piwik server.

Installation

This library can be installed via composer: "piotr-cz/monolog-piwik-handler": "~1.0"

$ composer require piotr-cz/monolog-piwik-handler

Example use

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]);

Requirements

  • PHP 5.3+

License

Released under the MIT License

Releases

No releases published

Packages

No packages published

Languages