Skip to content

Instantly share code, notes, and snippets.

@kaioken
Created October 27, 2018 05:52
Show Gist options
  • Select an option

  • Save kaioken/b8eabd2d2144989842f7ef38809e418d to your computer and use it in GitHub Desktop.

Select an option

Save kaioken/b8eabd2d2144989842f7ef38809e418d to your computer and use it in GitHub Desktop.
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