From c7cae859036a137c59db70d8cb129f02d1c24e33 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 4 Jan 2018 15:28:58 -0600 Subject: [PATCH] [5.6] Rework Logging (#22635) 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. --- src/Illuminate/Contracts/Logging/Log.php | 98 ---- src/Illuminate/Foundation/Application.php | 2 +- src/Illuminate/Foundation/helpers.php | 15 +- src/Illuminate/Log/LogManager.php | 521 ++++++++++++++++++ src/Illuminate/Log/LogServiceProvider.php | 141 +---- src/Illuminate/Log/{Writer.php => Logger.php} | 151 +---- src/Illuminate/Support/Facades/Log.php | 2 +- tests/Log/LogWriterTest.php | 31 +- 8 files changed, 569 insertions(+), 392 deletions(-) delete mode 100644 src/Illuminate/Contracts/Logging/Log.php create mode 100644 src/Illuminate/Log/LogManager.php rename src/Illuminate/Log/{Writer.php => Logger.php} (62%) diff --git a/src/Illuminate/Contracts/Logging/Log.php b/src/Illuminate/Contracts/Logging/Log.php deleted file mode 100644 index 5ecb9f8bdcf4..000000000000 --- a/src/Illuminate/Contracts/Logging/Log.php +++ /dev/null @@ -1,98 +0,0 @@ - [\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], diff --git a/src/Illuminate/Foundation/helpers.php b/src/Illuminate/Foundation/helpers.php index ffb1ca53f6cc..088863c69c06 100644 --- a/src/Illuminate/Foundation/helpers.php +++ b/src/Illuminate/Foundation/helpers.php @@ -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 = []) { @@ -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. diff --git a/src/Illuminate/Log/LogManager.php b/src/Illuminate/Log/LogManager.php new file mode 100644 index 000000000000..f3011b81e097 --- /dev/null +++ b/src/Illuminate/Log/LogManager.php @@ -0,0 +1,521 @@ + Monolog::DEBUG, + 'info' => Monolog::INFO, + 'notice' => Monolog::NOTICE, + 'warning' => Monolog::WARNING, + 'error' => Monolog::ERROR, + 'critical' => Monolog::CRITICAL, + 'alert' => Monolog::ALERT, + 'emergency' => Monolog::EMERGENCY, + ]; + + /** + * Create a new Log manager instance. + * + * @param \Illuminate\Foundation\Application $app + * @return void + */ + public function __construct($app) + { + $this->app = $app; + } + + /** + * Get a log channel instance. + * + * @param string $driver + * @return mixed + */ + public function channel($channel = null) + { + return $this->driver($channel); + } + + /** + * Get a log driver instance. + * + * @param string $driver + * @return mixed + */ + public function driver($driver = null) + { + return $this->get($driver ?? $this->getDefaultDriver()); + } + + /** + * Attempt to get the log from the local cache. + * + * @param string $name + * @return \Psr\Log\LoggerInterface + */ + protected function get($name) + { + try { + return $this->stores[$name] ?? with($this->resolve($name), function ($monolog) use ($name) { + return $this->tap($name, new Logger($monolog, $this->app['events'])); + }); + } catch (Throwable $e) { + return tap($this->createEmergencyLogger(), function ($logger) use ($e) { + $logger->emergency('Unable to create configured logger. Using emergency logger.', [ + 'exception' => $e, + ]); + }); + } + } + + /** + * Apply the configured taps for the logger. + * + * @param string $name + * @param \Illuminate\Log\Logger $logger + * @return \Illuminate\Log\Logger + */ + protected function tap($name, Logger $logger) + { + foreach ($this->configurationFor($name)['tap'] ?? [] as $tap) { + list($class, $arguments) = $this->parseTap($tap); + + $this->app->make($class)->__invoke($logger, ...explode(',', $arguments)); + } + + return $logger; + } + + /** + * Parse the given tap class string into a class name and arguments string. + * + * @param string $tap + * @return array + */ + protected function parseTap($tap) + { + return Str::contains($tap, ':') ? explode(':', $tap, 2) : [$tap, '']; + } + + /** + * Create an emergency log handler to avoid white screens of death. + * + * @return \Psr\Log\LoggerInterface + */ + protected function createEmergencyLogger() + { + return new Logger(new Monolog('laravel', $this->prepareHandlers([new StreamHandler( + $this->app->storagePath().'/logs/laravel.log', $this->level(['level' => 'debug']) + )])), $this->app['events']); + } + + /** + * Resolve the given log instance by name. + * + * @param string $name + * @return \Psr\Log\LoggerInterface + * + * @throws \InvalidArgumentException + */ + protected function resolve($name) + { + $config = $this->configurationFor($name); + + if (is_null($config)) { + throw new InvalidArgumentException("Log [{$name}] is not defined."); + } + + if (isset($this->customCreators[$config['driver']])) { + return $this->callCustomCreator($config); + } else { + $driverMethod = 'create'.ucfirst($config['driver']).'Driver'; + + if (method_exists($this, $driverMethod)) { + return $this->{$driverMethod}($config); + } else { + throw new InvalidArgumentException("Driver [{$config['driver']}] is not supported."); + } + } + } + + /** + * Call a custom driver creator. + * + * @param array $config + * @return mixed + */ + protected function callCustomCreator(array $config) + { + return $this->customCreators[$config['driver']]($this->app, $config); + } + + /** + * Create a custom log driver instance. + * + * @param array $config + * @return \Psr\Log\LoggerInterface + */ + protected function createCustomDriver(array $config) + { + return $this->app->make($config['via'])->__invoke($config); + } + + /** + * Create an instance of the single file log driver. + * + * @param array $config + * @return \Psr\Log\LoggerInterface + */ + protected function createSingleDriver(array $config) + { + return new Monolog($this->parseChannel($config), [ + $this->prepareHandler( + new StreamHandler($config['path'], $this->level($config)) + ), + ]); + } + + /** + * Create an instance of the daily file log driver. + * + * @param array $config + * @return \Psr\Log\LoggerInterface + */ + protected function createDailyDriver(array $config) + { + return new Monolog($this->parseChannel($config), [ + $this->prepareHandler(new RotatingFileHandler( + $config['path'], $config['days'] ?? 7, $this->level($config) + )), + ]); + } + + /** + * Create an instance of the syslog log driver. + * + * @param array $config + * @return \Psr\Log\LoggerInterface + */ + protected function createSyslogDriver(array $config) + { + return new Monolog($this->parseChannel($config), [ + $this->prepareHandler(new SyslogHandler( + $this->app['config']['app.name'], $config['facility'] ?? LOG_USER, $this->level($config)) + ), + ]); + } + + /** + * Create an instance of the "error log" log driver. + * + * @param array $config + * @return \Psr\Log\LoggerInterface + */ + protected function createErrorlogDriver(array $config) + { + return new Monolog($this->parseChannel($config), [ + $this->prepareHandler(new ErrorLogHandler( + $config['type'] ?? ErrorLogHandler::OPERATING_SYSTEM, $this->level($config)) + ), + ]); + } + + /** + * Prepare the handlers for usage by Monolog. + * + * @param array $handlers + * @return \Monolog\Handler\HandlerInterface + */ + protected function prepareHandlers(array $handlers) + { + foreach ($handlers as $key => $handler) { + $handlers[$key] = $this->prepareHandler($handler); + } + + return $handlers; + } + + /** + * Prepare the handler for usage by Monolog. + * + * @param \Monolog\Handler\HandlerInterface $handler + * @return \Monolog\Handler\HandlerInterface + */ + protected function prepareHandler(HandlerInterface $handler) + { + return $handler->setFormatter($this->formatter()); + } + + /** + * Get a Monolog formatter instance. + * + * @return \Monolog\Formatter\FormatterInterface + */ + protected function formatter() + { + return tap(new LineFormatter(null, null, true, true), function ($formatter) { + $formatter->includeStacktraces(); + }); + } + + /** + * Extract the log channel from the given configuration. + * + * @param array $config + * @return string + */ + protected function parseChannel(array $config) + { + if (! isset($config['channel'])) { + return $this->app->bound('env') ? $this->app->environment() : 'production'; + } + + return $config['channel']; + } + + /** + * Parse the string level into a Monolog constant. + * + * @param array $config + * @return int + * + * @throws \InvalidArgumentException + */ + protected function level(array $config) + { + $level = $config['level'] ?? 'debug'; + + if (isset($this->levels[$level])) { + return $this->levels[$level]; + } + + throw new InvalidArgumentException('Invalid log level.'); + } + + /** + * Get the log connection configuration. + * + * @param string $name + * @return array + */ + protected function configurationFor($name) + { + return $this->app['config']["logging.channels.{$name}"]; + } + + /** + * Get the default log driver name. + * + * @return string + */ + public function getDefaultDriver() + { + return $this->app['config']['logging.default']; + } + + /** + * Set the default log driver name. + * + * @param string $name + * @return void + */ + public function setDefaultDriver($name) + { + $this->app['config']['logging.default'] = $name; + } + + /** + * Register a custom driver creator Closure. + * + * @param string $driver + * @param \Closure $callback + * @return $this + */ + public function extend($driver, Closure $callback) + { + $this->customCreators[$driver] = $callback->bindTo($this, $this); + + return $this; + } + + /** + * System is unusable. + * + * @param string $message + * @param array $context + * + * @return void + */ + public function emergency($message, array $context = []) + { + return $this->driver()->emergency($message, $context); + } + + /** + * Action must be taken immediately. + * + * Example: Entire website down, database unavailable, etc. This should + * trigger the SMS alerts and wake you up. + * + * @param string $message + * @param array $context + * + * @return void + */ + public function alert($message, array $context = []) + { + return $this->driver()->alert($message, $context); + } + + /** + * Critical conditions. + * + * Example: Application component unavailable, unexpected exception. + * + * @param string $message + * @param array $context + * + * @return void + */ + public function critical($message, array $context = []) + { + return $this->driver()->critical($message, $context); + } + + /** + * Runtime errors that do not require immediate action but should typically + * be logged and monitored. + * + * @param string $message + * @param array $context + * + * @return void + */ + public function error($message, array $context = []) + { + return $this->driver()->error($message, $context); + } + + /** + * Exceptional occurrences that are not errors. + * + * Example: Use of deprecated APIs, poor use of an API, undesirable things + * that are not necessarily wrong. + * + * @param string $message + * @param array $context + * + * @return void + */ + public function warning($message, array $context = []) + { + return $this->driver()->warning($message, $context); + } + + /** + * Normal but significant events. + * + * @param string $message + * @param array $context + * + * @return void + */ + public function notice($message, array $context = []) + { + return $this->driver()->notice($message, $context); + } + + /** + * Interesting events. + * + * Example: User logs in, SQL logs. + * + * @param string $message + * @param array $context + * + * @return void + */ + public function info($message, array $context = []) + { + return $this->driver()->info($message, $context); + } + + /** + * Detailed debug information. + * + * @param string $message + * @param array $context + * + * @return void + */ + public function debug($message, array $context = []) + { + return $this->driver()->debug($message, $context); + } + + /** + * Logs with an arbitrary level. + * + * @param mixed $level + * @param string $message + * @param array $context + * + * @return void + */ + public function log($level, $message, array $context = []) + { + return $this->driver()->log($message, $context); + } + + /** + * Dynamically call the default driver instance. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + return $this->driver()->$method(...$parameters); + } +} diff --git a/src/Illuminate/Log/LogServiceProvider.php b/src/Illuminate/Log/LogServiceProvider.php index 306284d68a73..cd0739211932 100644 --- a/src/Illuminate/Log/LogServiceProvider.php +++ b/src/Illuminate/Log/LogServiceProvider.php @@ -2,7 +2,6 @@ namespace Illuminate\Log; -use Monolog\Logger as Monolog; use Illuminate\Support\ServiceProvider; class LogServiceProvider extends ServiceProvider @@ -15,145 +14,7 @@ class LogServiceProvider extends ServiceProvider public function register() { $this->app->singleton('log', function () { - return $this->createLogger(); + return new LogManager($this->app); }); } - - /** - * Create the logger. - * - * @return \Illuminate\Log\Writer - */ - public function createLogger() - { - $log = new Writer( - new Monolog($this->channel()), $this->app['events'] - ); - - if ($this->app->hasMonologConfigurator()) { - call_user_func($this->app->getMonologConfigurator(), $log->getMonolog()); - } else { - $this->configureHandler($log); - } - - return $log; - } - - /** - * Get the name of the log "channel". - * - * @return string - */ - protected function channel() - { - if ($this->app->bound('config') && - $channel = $this->app->make('config')->get('app.log_channel')) { - return $channel; - } - - return $this->app->bound('env') ? $this->app->environment() : 'production'; - } - - /** - * Configure the Monolog handlers for the application. - * - * @param \Illuminate\Log\Writer $log - * @return void - */ - protected function configureHandler(Writer $log) - { - $this->{'configure'.ucfirst($this->handler()).'Handler'}($log); - } - - /** - * Configure the Monolog handlers for the application. - * - * @param \Illuminate\Log\Writer $log - * @return void - */ - protected function configureSingleHandler(Writer $log) - { - $log->useFiles( - $this->app->storagePath().'/logs/laravel.log', - $this->logLevel() - ); - } - - /** - * Configure the Monolog handlers for the application. - * - * @param \Illuminate\Log\Writer $log - * @return void - */ - protected function configureDailyHandler(Writer $log) - { - $log->useDailyFiles( - $this->app->storagePath().'/logs/laravel.log', $this->maxFiles(), - $this->logLevel() - ); - } - - /** - * Configure the Monolog handlers for the application. - * - * @param \Illuminate\Log\Writer $log - * @return void - */ - protected function configureSyslogHandler(Writer $log) - { - $log->useSyslog($this->app->make('config')->get('app.name'), $this->logLevel()); - } - - /** - * Configure the Monolog handlers for the application. - * - * @param \Illuminate\Log\Writer $log - * @return void - */ - protected function configureErrorlogHandler(Writer $log) - { - $log->useErrorLog($this->logLevel()); - } - - /** - * Get the default log handler. - * - * @return string - */ - protected function handler() - { - if ($this->app->bound('config')) { - return $this->app->make('config')->get('app.log', 'single'); - } - - return 'single'; - } - - /** - * Get the log level for the application. - * - * @return string - */ - protected function logLevel() - { - if ($this->app->bound('config')) { - return $this->app->make('config')->get('app.log_level', 'debug'); - } - - return 'debug'; - } - - /** - * Get the maximum number of log files for the application. - * - * @return int - */ - protected function maxFiles() - { - if ($this->app->bound('config')) { - return $this->app->make('config')->get('app.log_max_files', 5); - } - - return 0; - } } diff --git a/src/Illuminate/Log/Writer.php b/src/Illuminate/Log/Logger.php similarity index 62% rename from src/Illuminate/Log/Writer.php rename to src/Illuminate/Log/Logger.php index acf77b2dbd95..e2010846c85b 100755 --- a/src/Illuminate/Log/Writer.php +++ b/src/Illuminate/Log/Logger.php @@ -4,28 +4,20 @@ use Closure; use RuntimeException; -use InvalidArgumentException; -use Monolog\Handler\StreamHandler; -use Monolog\Handler\SyslogHandler; -use Monolog\Formatter\LineFormatter; -use Monolog\Handler\ErrorLogHandler; -use Monolog\Logger as MonologLogger; +use Psr\Log\LoggerInterface; use Illuminate\Log\Events\MessageLogged; -use Monolog\Handler\RotatingFileHandler; use Illuminate\Contracts\Support\Jsonable; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Support\Arrayable; -use Psr\Log\LoggerInterface as PsrLoggerInterface; -use Illuminate\Contracts\Logging\Log as LogContract; -class Writer implements LogContract, PsrLoggerInterface +class Logger implements LoggerInterface { /** - * The Monolog logger instance. + * The underlying logger implementation. * - * @var \Monolog\Logger + * @var \Psr\Log\LoggerInterface */ - protected $monolog; + protected $logger; /** * The event dispatcher instance. @@ -34,32 +26,16 @@ class Writer implements LogContract, PsrLoggerInterface */ protected $dispatcher; - /** - * The Log levels. - * - * @var array - */ - protected $levels = [ - 'debug' => MonologLogger::DEBUG, - 'info' => MonologLogger::INFO, - 'notice' => MonologLogger::NOTICE, - 'warning' => MonologLogger::WARNING, - 'error' => MonologLogger::ERROR, - 'critical' => MonologLogger::CRITICAL, - 'alert' => MonologLogger::ALERT, - 'emergency' => MonologLogger::EMERGENCY, - ]; - /** * Create a new log writer instance. * - * @param \Monolog\Logger $monolog + * @param \Psr\Log\LoggerInterface $logger * @param \Illuminate\Contracts\Events\Dispatcher|null $dispatcher * @return void */ - public function __construct(MonologLogger $monolog, Dispatcher $dispatcher = null) + public function __construct(LoggerInterface $logger, Dispatcher $dispatcher = null) { - $this->monolog = $monolog; + $this->logger = $logger; if (isset($dispatcher)) { $this->dispatcher = $dispatcher; @@ -189,7 +165,7 @@ public function write($level, $message, array $context = []) } /** - * Write a message to Monolog. + * Write a message to the log. * * @param string $level * @param string $message @@ -200,65 +176,7 @@ protected function writeLog($level, $message, $context) { $this->fireLogEvent($level, $message = $this->formatMessage($message), $context); - $this->monolog->{$level}($message, $context); - } - - /** - * Register a file log handler. - * - * @param string $path - * @param string $level - * @return void - */ - public function useFiles($path, $level = 'debug') - { - $this->monolog->pushHandler($handler = new StreamHandler($path, $this->parseLevel($level))); - - $handler->setFormatter($this->getDefaultFormatter()); - } - - /** - * Register a daily file log handler. - * - * @param string $path - * @param int $days - * @param string $level - * @return void - */ - public function useDailyFiles($path, $days = 0, $level = 'debug') - { - $this->monolog->pushHandler( - $handler = new RotatingFileHandler($path, $days, $this->parseLevel($level)) - ); - - $handler->setFormatter($this->getDefaultFormatter()); - } - - /** - * Register a Syslog handler. - * - * @param string $name - * @param string $level - * @param mixed $facility - * @return \Psr\Log\LoggerInterface - */ - public function useSyslog($name = 'laravel', $level = 'debug', $facility = LOG_USER) - { - return $this->monolog->pushHandler(new SyslogHandler($name, $facility, $level)); - } - - /** - * Register an error_log handler. - * - * @param string $level - * @param int $messageType - * @return void - */ - public function useErrorLog($level = 'debug', $messageType = ErrorLogHandler::OPERATING_SYSTEM) - { - $this->monolog->pushHandler( - new ErrorLogHandler($messageType, $this->parseLevel($level)) - ); + $this->logger->{$level}($message, $context); } /** @@ -316,42 +234,13 @@ protected function formatMessage($message) } /** - * Parse the string level into a Monolog constant. - * - * @param string $level - * @return int + * Get the underlying logger implementation. * - * @throws \InvalidArgumentException - */ - protected function parseLevel($level) - { - if (isset($this->levels[$level])) { - return $this->levels[$level]; - } - - throw new InvalidArgumentException('Invalid log level.'); - } - - /** - * Get the underlying Monolog instance. - * - * @return \Monolog\Logger - */ - public function getMonolog() - { - return $this->monolog; - } - - /** - * Get a default Monolog formatter instance. - * - * @return \Monolog\Formatter\LineFormatter + * @return \Psr\Log\LoggerInterface */ - protected function getDefaultFormatter() + public function getLogger() { - return tap(new LineFormatter(null, null, true, true), function ($formatter) { - $formatter->includeStacktraces(); - }); + return $this->logger; } /** @@ -374,4 +263,16 @@ public function setEventDispatcher(Dispatcher $dispatcher) { $this->dispatcher = $dispatcher; } + + /** + * Dynamically proxy method calls to the underlying logger. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + return $this->logger->{$method}(...$parameters); + } } diff --git a/src/Illuminate/Support/Facades/Log.php b/src/Illuminate/Support/Facades/Log.php index b10e064788c3..b28c6aca4c40 100755 --- a/src/Illuminate/Support/Facades/Log.php +++ b/src/Illuminate/Support/Facades/Log.php @@ -5,7 +5,7 @@ use Psr\Log\LoggerInterface; /** - * @see \Illuminate\Log\Writer + * @see \Illuminate\Log\Logger */ class Log extends Facade { diff --git a/tests/Log/LogWriterTest.php b/tests/Log/LogWriterTest.php index 8b649a37c933..bf7f7f38e18c 100755 --- a/tests/Log/LogWriterTest.php +++ b/tests/Log/LogWriterTest.php @@ -3,7 +3,7 @@ namespace Illuminate\Tests\Log; use Mockery as m; -use Illuminate\Log\Writer; +use Illuminate\Log\Logger; use PHPUnit\Framework\TestCase; class LogWriterTest extends TestCase @@ -13,30 +13,9 @@ public function tearDown() m::close(); } - public function testFileHandlerCanBeAdded() - { - $writer = new Writer($monolog = m::mock('Monolog\Logger')); - $monolog->shouldReceive('pushHandler')->once()->with(m::type('Monolog\Handler\StreamHandler')); - $writer->useFiles(__DIR__); - } - - public function testRotatingFileHandlerCanBeAdded() - { - $writer = new Writer($monolog = m::mock('Monolog\Logger')); - $monolog->shouldReceive('pushHandler')->once()->with(m::type('Monolog\Handler\RotatingFileHandler')); - $writer->useDailyFiles(__DIR__, 5); - } - - public function testErrorLogHandlerCanBeAdded() - { - $writer = new Writer($monolog = m::mock('Monolog\Logger')); - $monolog->shouldReceive('pushHandler')->once()->with(m::type('Monolog\Handler\ErrorLogHandler')); - $writer->useErrorLog(); - } - public function testMethodsPassErrorAdditionsToMonolog() { - $writer = new Writer($monolog = m::mock('Monolog\Logger')); + $writer = new Logger($monolog = m::mock('Monolog\Logger')); $monolog->shouldReceive('error')->once()->with('foo', []); $writer->error('foo'); @@ -44,7 +23,7 @@ public function testMethodsPassErrorAdditionsToMonolog() public function testWriterFiresEventsDispatcher() { - $writer = new Writer($monolog = m::mock('Monolog\Logger'), $events = new \Illuminate\Events\Dispatcher); + $writer = new Logger($monolog = m::mock('Monolog\Logger'), $events = new \Illuminate\Events\Dispatcher); $monolog->shouldReceive('error')->once()->with('foo', []); $events->listen(\Illuminate\Log\Events\MessageLogged::class, function ($event) { @@ -71,14 +50,14 @@ public function testWriterFiresEventsDispatcher() */ public function testListenShortcutFailsWithNoDispatcher() { - $writer = new Writer($monolog = m::mock('Monolog\Logger')); + $writer = new Logger($monolog = m::mock('Monolog\Logger')); $writer->listen(function () { }); } public function testListenShortcut() { - $writer = new Writer($monolog = m::mock('Monolog\Logger'), $events = m::mock('Illuminate\Contracts\Events\Dispatcher')); + $writer = new Logger($monolog = m::mock('Monolog\Logger'), $events = m::mock('Illuminate\Contracts\Events\Dispatcher')); $callback = function () { return 'success';