本文整理汇总了PHP中Log::getMonolog方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::getMonolog方法的具体用法?PHP Log::getMonolog怎么用?PHP Log::getMonolog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Log
的用法示例。
在下文中一共展示了Log::getMonolog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
$this->publishes(array(__DIR__ . '/../../config/config.php' => config_path('epilog.php')));
$logger = \Log::getMonolog();
// Additional info in message
$logger->pushProcessor(function ($record) {
$info = '';
if (\Auth::check()) {
$info .= 'User #' . \Auth::user()->id . ' (' . \Auth::user()->email . ') - ';
}
if (isset($_SERVER['REMOTE_ADDR'])) {
$info .= 'IP: ' . $_SERVER['REMOTE_ADDR'];
}
if (isset($_SERVER['REQUEST_URI'])) {
$info .= "\n" . $_SERVER['REQUEST_METHOD'] . " " . url($_SERVER['REQUEST_URI']);
}
if (isset($_SERVER['HTTP_REFERER'])) {
$info .= "\nReferer: " . $_SERVER['HTTP_REFERER'];
}
if ($info) {
$info = "\n---\n{$info}\n---";
if (strpos($record['message'], "\n")) {
$record['message'] = preg_replace("/\n/", $info . "\n", $record['message'], 1);
} else {
$record['message'] .= $info . "\n";
}
}
return $record;
});
// Slack notification
if (app()->environment(config('epilog.slack.env'))) {
$slackHandler = new \Monolog\Handler\SlackHandler(config('epilog.slack.token'), config('epilog.slack.channel'), config('epilog.slack.username'), true, ':skull:', \Monolog\Logger::ERROR, true, true, true);
$logger->pushHandler($slackHandler);
}
}
示例2: __construct
public function __construct()
{
/* Set the Language Based on Agent Browser */
$languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$lang = substr($languages[0], 0, 2);
App::setLocale($lang);
/* Load Assets */
Asset::add('bootstraptheme', 'assets/css/bootstrap-spacelab.css');
Asset::add('bootstrapresponsive', 'assets/css/bootstrap-responsive.css');
Asset::add('charisma', 'assets/css/charisma-app.css');
Asset::add('uniform', 'assets/css/uniform.default.css');
Asset::add('elfinder', 'assets/css/elfinder.min.css');
Asset::add('opaicons', 'assets/css/opa-icons.css');
Asset::add('famfam', 'assets/css/famfam.css');
Asset::add('jqueryloadermin', 'assets/css/jquery.loader-min.css');
Asset::add('reportula', 'assets/css/reportula.css');
Asset::add('jquery', 'assets/js/jquery-2.0.3.min.js');
Asset::add('datatables', 'assets/js/jquery.dataTables.min.js', 'jquery');
Asset::add('jqueryloader', 'assets/js/jquery.loader-min.js', 'jquery');
Asset::add('main', 'assets/js/main.js', 'TableTools');
Asset::add('modal', 'assets/js/bootstrap-modal.js', 'jquery');
/* Get Monolog instance from Laravel */
$monolog = Log::getMonolog();
/* Add the FirePHP handler */
$monolog->pushHandler(new \Monolog\Handler\FirePHPHandler());
/* Resolve Database Names Myslq and Postgres */
if (Config::get('database.default') == 'mysql') {
$this->tables = array('job' => 'Job', 'client' => 'Client', 'files' => 'Files', 'media' => 'Media', 'pool' => 'Pool', 'path' => 'Path', 'filename' => 'Filename', 'file' => 'File', 'jobfiles' => 'JobFiles', 'jobmedia' => 'JobMedia');
} else {
$this->tables = array('job' => 'job', 'client' => 'client', 'files' => 'files', 'media' => 'media', 'pool' => 'pool', 'path' => 'path', 'filename' => 'filename', 'file' => 'file', 'jobfiles' => 'jobfiles', 'jobmedia' => 'jobmedia');
}
}
示例3: registerRuntimeConfiguration
/**
* Register propel runtime configuration.
*
* @return void
*/
protected function registerRuntimeConfiguration()
{
$propel_conf = $this->app->config['propel.propel'];
if (!isset($propel_conf['runtime']['connections'])) {
throw new \InvalidArgumentException('Unable to guess Propel runtime config file. Please, initialize the "propel.runtime" parameter.');
}
/** @var $serviceContainer \Propel\Runtime\ServiceContainer\StandardServiceContainer */
$serviceContainer = Propel::getServiceContainer();
$serviceContainer->closeConnections();
$serviceContainer->checkVersion('2.0.0-dev');
$runtime_conf = $propel_conf['runtime'];
// set connections
foreach ($runtime_conf['connections'] as $connection_name) {
$config = $propel_conf['database']['connections'][$connection_name];
$serviceContainer->setAdapterClass($connection_name, $config['adapter']);
$manager = new ConnectionManagerSingle();
$manager->setConfiguration($config + [$propel_conf['paths']]);
$manager->setName($connection_name);
$serviceContainer->setConnectionManager($connection_name, $manager);
}
$serviceContainer->setDefaultDatasource($runtime_conf['defaultConnection']);
// set loggers
$has_default_logger = false;
if (isset($runtime_conf['log'])) {
$has_default_logger = array_key_exists('defaultLogger', $runtime_conf['log']);
foreach ($runtime_conf['log'] as $logger_name => $logger_conf) {
$serviceContainer->setLoggerConfiguration($logger_name, $logger_conf);
}
}
if (!$has_default_logger) {
$serviceContainer->setLogger('defaultLogger', \Log::getMonolog());
}
Propel::setServiceContainer($serviceContainer);
}
示例4: getMonolog
protected static function getMonolog()
{
// Use facade if it is available
if (class_exists('Log')) {
return \Log::getMonolog();
}
// otherwise create a new instance
return parent::getMonolog();
}
示例5: boot
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$app = $this->app;
// Listen to log messages.
$app['log']->listen(function () use($app) {
$logger = \Log::getMonolog();
$logger->pushHandler($app['loggly.handler']);
});
}
示例6: register
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->bind('Psr\\Log\\LoggerInterface', function () {
return \Log::getMonolog();
});
$this->app->bind('App\\Basket\\Notifications\\LocationNotificationService', 'App\\Basket\\Notifications\\EmailLocationNotificationService');
$this->app->bind('PayBreak\\Sdk\\ApiClient\\ApiClientFactoryInterface', 'App\\Gateways\\ApiClientFactory');
$this->app->when('PayBreak\\Sdk\\Gateways\\SettlementCsvGateway')->needs('PayBreak\\Sdk\\ApiClient\\ApiClientFactoryInterface')->give('App\\Gateways\\ApiCsvClientFactory');
}
示例7: register
public function register()
{
$this->app->singleton('groundsix.profiler', function () {
return new \GroundSix\Component\StatsProfiler();
});
$monolog = \Log::getMonolog();
$this->app['groundsix.profiler']->setLogger($monolog);
$this->app['groundsix.profiler']->push("Provider registered");
}
示例8: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$logger = \Log::getMonolog();
try {
$service = LogKeeperServiceFactory::buildFromLaravelConfig();
$logger = $service->getLogger();
$service->work();
} catch (Exception $e) {
$logger->error("Something went wrong: {$e->getMessage()}");
}
}
示例9: app_path
*/
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/models', app_path() . '/database/seeds', app_path() . '/util', app_path() . '/services', app_path() . '/builders'));
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
$logFile = 'atlas.log';
Log::useDailyFiles(storage_path() . '/logs/' . $logFile, 7, Config::get('app.log-level'));
if (App::environment() == 'local') {
$monolog = Log::getMonolog();
$monolog->pushHandler(new \Monolog\Handler\ChromePHPHandler());
}
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
| logging them or displaying custom views for specific errors. You may
| even register several error handlers to handle different types of
| exceptions. If nothing is returned, the default error view is
| shown, which includes a detailed stack trace during debug.
|
*/
App::error(function (Exception $exception, $code) {
示例10: makeApiClient
/**
* @author EA
* @param string $token
* @return ProviderApiClient
*/
public function makeApiClient($token)
{
return ProviderCsvApiClient::make(config('basket.providerUrl'), $token, \Log::getMonolog());
}
示例11: __construct
public function __construct()
{
parent::__construct();
$this->log = \Log::getMonolog();
}
示例12: app_path
| your classes in the "global" namespace without Composer updating.
|
*/
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/models', app_path() . '/database/seeds'));
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
Log::useFiles(storage_path() . '/logs/laravel.log');
Log::getMonolog()->pushHandler(new \Monolog\Handler\StreamHandler('php://stderr', \Monolog\Logger::WARNING));
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
| logging them or displaying custom views for specific errors. You may
| even register several error handlers to handle different types of
| exceptions. If nothing is returned, the default error view is
| shown, which includes a detailed stack trace during debug.
|
*/
App::error(function (Exception $exception, $code) {
Log::error($exception);
});
示例13: bootLoggly
private function bootLoggly()
{
$logglyHandler = new LogglyHandler(config('services.loggly.token'));
$logglyHandler->setFormatter(new LogglyFormatter());
\Log::getMonolog()->pushHandler($logglyHandler);
}
示例14: app_path
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/models', app_path() . '/database/seeds'));
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
Log::useFiles(storage_path() . '/logs/laravel.log');
if (Config::get('app.logglykey') && Config::get('app.logglytag')) {
$handler = new \Monolog\Handler\LogglyHandler(Config::get('app.logglykey'), \Monolog\Logger::DEBUG);
$handler->setTag(Config::get('app.logglytag'));
$logger = Log::getMonolog();
$logger->pushHandler($handler);
}
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
| logging them or displaying custom views for specific errors. You may
| even register several error handlers to handle different types of
| exceptions. If nothing is returned, the default error view is
| shown, which includes a detailed stack trace during debug.
|
*/
/** @noinspection PhpUnusedParameterInspection */
示例15: boot
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$this->publishes([__DIR__ . '/../config/propel.php' => config_path('propel.php')]);
if (!$this->app->config['propel.propel.runtime.connections']) {
throw new \InvalidArgumentException('Unable to guess Propel runtime config file. Please, initialize the "propel.runtime" parameter.');
}
// load pregenerated config
if (file_exists(app_path() . '/propel/config.php')) {
Propel::init(app_path() . '/propel/config.php');
return;
}
// runtime configuration
/** @var \Propel\Runtime\ServiceContainer\StandardServiceContainer */
$serviceContainer = \Propel\Runtime\Propel::getServiceContainer();
$serviceContainer->closeConnections();
$serviceContainer->checkVersion('2.0.0-dev');
$propel_conf = $this->app->config['propel.propel'];
$runtime_conf = $propel_conf['runtime'];
// set connections
foreach ($runtime_conf['connections'] as $connection_name) {
$config = $propel_conf['database']['connections'][$connection_name];
if (!isset($config['classname'])) {
if ($this->app->config['app.debug']) {
$config['classname'] = '\\Propel\\Runtime\\Connection\\DebugPDO';
} else {
$config['classname'] = '\\Propel\\Runtime\\Connection\\ConnectionWrapper';
}
}
$serviceContainer->setAdapterClass($connection_name, $config['adapter']);
$manager = new \Propel\Runtime\Connection\ConnectionManagerSingle();
$manager->setConfiguration($config + [$propel_conf['paths']]);
$manager->setName($connection_name);
$serviceContainer->setConnectionManager($connection_name, $manager);
}
$serviceContainer->setDefaultDatasource($runtime_conf['defaultConnection']);
// set loggers
$has_default_logger = false;
if (isset($runtime_conf['log'])) {
foreach ($runtime_conf['log'] as $logger_name => $logger_conf) {
$serviceContainer->setLoggerConfiguration($logger_name, $logger_conf);
$has_default_logger |= $logger_name === 'defaultLogger';
}
}
if (!$has_default_logger) {
$serviceContainer->setLogger('defaultLogger', \Log::getMonolog());
}
Propel::setServiceContainer($serviceContainer);
$command = false;
if (\App::runningInConsole()) {
$input = new ArgvInput();
$command = $input->getFirstArgument();
}
// skip auth driver adding if running as CLI to avoid auth model not found
if ('propel:model:build' !== $command && 'propel' === \Config::get('auth.driver')) {
$query_name = \Config::get('auth.user_query', false);
if ($query_name) {
$query = new $query_name();
if (!$query instanceof Criteria) {
throw new InvalidConfigurationException("Configuration directive «auth.user_query» must contain valid classpath of user Query. Excpected type: instanceof Propel\\Runtime\\ActiveQuery\\Criteria");
}
} else {
$user_class = \Config::get('auth.model');
$query = new $user_class();
if (!method_exists($query, 'buildCriteria')) {
throw new InvalidConfigurationException("Configuration directive «auth.model» must contain valid classpath of model, which has method «buildCriteria()»");
}
$query = $query->buildPkeyCriteria();
$query->clear();
}
\Auth::extend('propel', function (\Illuminate\Foundation\Application $app) use($query) {
return new PropelUserProvider($query, $app->make('hash'));
});
}
}