Skip to content

Commit

Permalink
[5.6] Rework Logging (#22635)
Browse files Browse the repository at this point in the history
This is a re-write / re-work of many of @phroggyy's ideas to improve logging.

Implemented:

Multi-driver logging support so you can have multiple logging channels per app.
"Pipes" in @phroggyy's pull request have been re-worked as "taps". Allows customization of logging channel post-creation.
Continued support for functionality provided by configureMonologUsing maintained using custom driver type with factory invokable that returns any PSR3 compatible logger. This allows full customization of entire logging channel.
I decided not to implement Log::event functionality from PR because I think that would be better suited for something like a ShouldLog interface on the event itself (to complement ShouldBroadcast, etc.).

Primary breaking changes:

New log configuration file / settings.
configureMonologUsing now custom driver type.
Illuminate\Contracts\Log removed. Was literal duplication of PSR3 logging interface.
Illuminate\Log\Writer renamed to Illuminate\Log\Logger.
  • Loading branch information
taylorotwell committed Jan 4, 2018
1 parent 9e5a3ba commit c7cae85
Show file tree
Hide file tree
Showing 8 changed files with 569 additions and 392 deletions.
98 changes: 0 additions & 98 deletions src/Illuminate/Contracts/Logging/Log.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ public function registerCoreContainerAliases()
'filesystem.cloud' => [\Illuminate\Contracts\Filesystem\Cloud::class],
'hash' => [\Illuminate\Hashing\HashManager::class],
'translator' => [\Illuminate\Translation\Translator::class, \Illuminate\Contracts\Translation\Translator::class],
'log' => [\Illuminate\Log\Writer::class, \Illuminate\Contracts\Logging\Log::class, \Psr\Log\LoggerInterface::class],
'log' => [\Illuminate\Log\Logger::class, \Illuminate\Contracts\Logging\Log::class, \Psr\Log\LoggerInterface::class],
'mailer' => [\Illuminate\Mail\Mailer::class, \Illuminate\Contracts\Mail\Mailer::class, \Illuminate\Contracts\Mail\MailQueue::class],
'auth.password' => [\Illuminate\Auth\Passwords\PasswordBrokerManager::class, \Illuminate\Contracts\Auth\PasswordBrokerFactory::class],
'auth.password.broker' => [\Illuminate\Auth\Passwords\PasswordBroker::class, \Illuminate\Contracts\Auth\PasswordBroker::class],
Expand Down
15 changes: 14 additions & 1 deletion src/Illuminate/Foundation/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ function info($message, $context = [])
*
* @param string $message
* @param array $context
* @return \Illuminate\Contracts\Logging\Log|null
* @return \Illuminate\Log\LogManager|null
*/
function logger($message = null, array $context = [])
{
Expand All @@ -521,6 +521,19 @@ function logger($message = null, array $context = [])
}
}

if (! function_exists('logs')) {
/**
* Get a log driver instance.
*
* @param string $driver
* @return \Illuminate\Log\LogManager|\Psr\Log\LoggerInterface
*/
function logs($driver = null)
{
return $driver ? app('log')->driver($driver) : app('log');
}
}

if (! function_exists('method_field')) {
/**
* Generate a form field to spoof the HTTP verb used by forms.
Expand Down
Loading

0 comments on commit c7cae85

Please sign in to comment.