/**
  * @param string $ident String identifying the application within the syslog stream.
  * @param $facility Syslog facility.
  */
 public function __construct($ident = 'SilverStripe_log', $facility = LOG_USER)
 {
     $this->monolog = new \Monolog\Logger('application');
     $syslog = new \Monolog\Handler\SyslogHandler($ident, $facility, \Monolog\Logger::DEBUG);
     $formatter = new \Monolog\Formatter\LineFormatter("%level_name%: %message% %context%");
     $syslog->setFormatter($formatter);
     $this->monolog->pushHandler($syslog);
 }
示例#2
0
 public function __construct($channel = self::SILVERPOP_CHANNEL)
 {
     $this->_channel = $channel;
     $this->_logger = new \Monolog\Logger($this->_channel);
     $handler = new \Monolog\Handler\SyslogHandler(self::SILVERPOP_CHANNEL, 'local3', \Monolog\Logger::INFO);
     $formatter = new \Monolog\Formatter\LineFormatter(null, null, true, true);
     $handler->setFormatter($formatter);
     $this->_logger->pushHandler($handler);
 }
 public function init()
 {
     $logger = new Monolog\Logger($this->channel);
     if (!empty($this->stream_handler_filepath)) {
         $file_stream = new Monolog\Handler\StreamHandler($this->stream_handler_filepath);
         if ($this->use_json_formatter) {
             $stream->setFormatter(new Monolog\Formatter\JsonFormatter());
         }
         $logger->pushHandler($stream);
     }
     if (!empty($this->syslog_identity)) {
         $syslog = new Monolog\Handler\SyslogHandler($this->syslog_identity);
         if ($this->use_json_formatter) {
             $syslog->setFormatter(new Monolog\Formatter\JsonFormatter());
         }
         $logger->pushHandler($syslog);
     }
     Monolog\Registry::addLogger($logger, 'main');
     parent::init();
 }
 public function create($service, array $params = array())
 {
     if (!empty($params)) {
         throw new \Exception('AuditFactory does not support passing params.');
     }
     $obj = null;
     switch ($service) {
         case 'AuditLogger':
             $log = new \Monolog\Logger('audit');
             $syslog = new \Monolog\Handler\SyslogHandler('SilverStripe_audit', LOG_AUTH, \Monolog\Logger::DEBUG);
             $syslog->pushProcessor(new \Monolog\Processor\WebProcessor($_SERVER, array('url' => 'REQUEST_URI', 'http_method' => 'REQUEST_METHOD', 'server' => 'SERVER_NAME', 'referrer' => 'HTTP_REFERER')));
             $syslog->pushProcessor(new RealIPProcessor());
             $formatter = new \Monolog\Formatter\LineFormatter("%level_name%: %message% %context% %extra%");
             $syslog->setFormatter($formatter);
             $log->pushHandler($syslog);
             return $log;
         default:
             throw new \Exception(sprintf("AuditFactory does not support creation of '%s'.", $service));
     }
 }
<?php

//temp, should go in service provider
$monolog = Log::getMonolog();
$syslog = new \Monolog\Handler\SyslogHandler('papertrail');
$formatter = new \Monolog\Formatter\LineFormatter('%channel%.%level_name%: %message% %extra%');
$syslog->setFormatter($formatter);
$monolog->pushHandler($syslog);
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
/**
 * OAuth.
 *
 */
Route::controller('oauth', 'OAuthController');
$group_attributes = [];
if (\App::environment() == 'service' || \App::environment() == 'local') {
    Route::get('admin-login', ['as' => 'user.admin-login', 'uses' => 'AuthController@adminAuthenticate']);
    Route::post('admin-login', 'AuthController@adminLogin');
    $group_attributes = ['before' => ['auth.admin', 'has_perm:_service-environment,admin']];
}
Route::group($group_attributes, function () {
    // Sentinel Routes
 protected function setServices()
 {
     // For papertrail
     if ($this->app->environment() == 'production') {
         $siteName = str_replace(['http://', 'https://'], '', $this->app['config']->get('app.url'));
         $monolog = Log::getMonolog();
         $syslog = new \Monolog\Handler\SyslogHandler($siteName);
         $formatter = new \Monolog\Formatter\LineFormatter('%channel%.%level_name%: %message% %extra%');
         $syslog->setFormatter($formatter);
         $monolog->pushHandler($syslog);
     }
 }