Skip to content

Instantly share code, notes, and snippets.

@kaioken kaioken/service.php
Created Oct 27, 2018

Embed
What would you like to do?
PhalconPHP Sentry.io Integration with Monolog
<?php
/**
* System Log using monolog
*/
$di->set('log', function ($file = 'debug') use ($config, $di) {
// Create the logger
$logger = new MonoLogger('GEWAER.API');
$client = new Raven_Client('https://' . getenv('SENTRY_RPOJECT_SECRET') . '@sentry.io/' . getenv('SENTRY_PROJECT_ID'));
//only report error logs to sentry
$handler = new Monolog\Handler\RavenHandler($client, MonoLogger::ERROR);
$handler->setFormatter(new Monolog\Formatter\LineFormatter("%message% %context% %extra%\n"));
$logger->pushHandler($handler);
$logger->pushHandler(new StreamHandler(APP_PATH . '/logs/' . $file . '.log', Logger::DEBUG));
return $logger;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.