Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.4] Cleanup log provider, remove passing app. #15794

Merged
merged 1 commit into from
Oct 7, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 15 additions & 22 deletions src/Illuminate/Log/LogServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Monolog\Logger as Monolog;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Foundation\Application;

class LogServiceProvider extends ServiceProvider
{
Expand All @@ -15,29 +14,28 @@ class LogServiceProvider extends ServiceProvider
*/
public function register()
{
$this->app->singleton('log', function ($app) {
return $this->createLogger($app);
$this->app->singleton('log', function () {
return $this->createLogger();
});
}

/**
* Create the logger.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return \Illuminate\Log\Writer
*/
public function createLogger($app)
public function createLogger()
{
$log = new Writer(
new Monolog($app->bound('env') ? $app->environment() : 'production'), $app['events']
new Monolog($this->app->bound('env') ? $this->app->environment() : 'production'), $this->app['events']
);

if ($app->hasMonologConfigurator()) {
if ($this->app->hasMonologConfigurator()) {
call_user_func(
$app->getMonologConfigurator(), $log->getMonolog()
$this->app->getMonologConfigurator(), $log->getMonolog()
);
} else {
$this->configureHandlers($app, $log);
$this->configureHandlers($log);
}

return $log;
Expand All @@ -46,11 +44,10 @@ public function createLogger($app)
/**
* Configure the Monolog handlers for the application.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Log\Writer $log
* @return void
*/
protected function configureHandlers(Application $app, Writer $log)
protected function configureHandlers(Writer $log)
{
if ($this->app->bound('config')) {
$handler = $this->app->make('config')->get('app.log');
Expand All @@ -60,59 +57,55 @@ protected function configureHandlers(Application $app, Writer $log)

$method = 'configure'.ucfirst($handler).'Handler';

$this->{$method}($app, $log);
$this->{$method}($log);
}

/**
* Configure the Monolog handlers for the application.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Log\Writer $log
* @return void
*/
protected function configureSingleHandler(Application $app, Writer $log)
protected function configureSingleHandler(Writer $log)
{
$log->useFiles(
$app->storagePath().'/logs/laravel.log',
$this->app->storagePath().'/logs/laravel.log',
$this->logLevel()
);
}

/**
* Configure the Monolog handlers for the application.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Log\Writer $log
* @return void
*/
protected function configureDailyHandler(Application $app, Writer $log)
protected function configureDailyHandler(Writer $log)
{
$log->useDailyFiles(
$app->storagePath().'/logs/laravel.log', $this->maxFiles(),
$this->app->storagePath().'/logs/laravel.log', $this->maxFiles(),
$this->logLevel()
);
}

/**
* Configure the Monolog handlers for the application.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Log\Writer $log
* @return void
*/
protected function configureSyslogHandler(Application $app, Writer $log)
protected function configureSyslogHandler(Writer $log)
{
$log->useSyslog('laravel', $this->logLevel());
}

/**
* Configure the Monolog handlers for the application.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Log\Writer $log
* @return void
*/
protected function configureErrorlogHandler(Application $app, Writer $log)
protected function configureErrorlogHandler(Writer $log)
{
$log->useErrorLog($this->logLevel());
}
Expand Down