From b1d543aa21fb8a45de1328f7ae9af5d5ce6a8111 Mon Sep 17 00:00:00 2001 From: agis Date: Fri, 25 Sep 2026 22:13:08 +0700 Subject: [PATCH] feat(log): swap illuminate/log to ^13 (task 4.3) v13 replaces the imperative Log\Writer (useFiles/useDailyFiles + log.setup closure) with a config-driven LogManager (reads config/logging.php channels; PSR-3). v13 Log\{LogManager,Logger,LogServiceProvider} shadow the fork tree via PSR-4 seed mechanism; the fork LogServiceProvider (Writer + log.setup) goes dead. - composer: illuminate/log self.version -> ^13 (v13.33.0; monolog ^3 already on floor). - registerCoreContainerAliases: 'log' -> Illuminate\Log\LogManager (was Log\Logger); drop the dead Log\Writer BC alias (v13 has no Writer). - Drop tests/Log/LogWriterTest.php (vendored-behavior: old Writer useFiles/getMonolog). Fork suite 579 green. App must author config/logging.php (matched-pair). Co-Authored-By: Claude Opus 4.8 (1M context) --- composer.json | 4 +- src/Illuminate/Foundation/Application.php | 5 +- tests/Log/LogWriterTest.php | 102 ---------------------- 3 files changed, 3 insertions(+), 108 deletions(-) delete mode 100755 tests/Log/LogWriterTest.php diff --git a/composer.json b/composer.json index 9f611488..c8d47a1a 100755 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ "illuminate/encryption": "^13", "illuminate/events": "^13", "illuminate/filesystem": "^13", - "illuminate/http": "^13", + "illuminate/http": "^13", + "illuminate/log": "^13", "illuminate/macroable": "^13", "illuminate/pagination": "^13", "illuminate/pipeline": "^13", @@ -64,7 +65,6 @@ "illuminate/foundation": "self.version", "illuminate/hashing": "self.version", "illuminate/html": "self.version", - "illuminate/log": "self.version", "illuminate/mail": "self.version", "illuminate/queue": "self.version", "illuminate/routing": "self.version", diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index c3fa38fb..f54bbe31 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -1258,7 +1258,7 @@ public function registerCoreContainerAliases() 'hash' => 'Illuminate\Contracts\Hashing\Hasher', 'html' => 'Illuminate\Html\HtmlBuilder', 'translator' => 'Illuminate\Translation\Translator', - 'log' => 'Illuminate\Log\Logger', + 'log' => 'Illuminate\Log\LogManager', 'mailer' => 'Illuminate\Mail\Mailer', 'auth.reminder' => 'Illuminate\Auth\Reminders\PasswordBroker', 'queue' => 'Illuminate\Queue\QueueManager', @@ -1278,9 +1278,6 @@ public function registerCoreContainerAliases() $this->alias($key, $alias); } - // BC: Log\Writer renamed to Log\Logger (task 3.5); keep old name resolvable. - $this->alias('log', 'Illuminate\Log\Writer'); - // Encrypter now implements the L13 contracts (task 2.9); resolve them to 'encrypter'. $this->alias('encrypter', 'Illuminate\Contracts\Encryption\Encrypter'); $this->alias('encrypter', 'Illuminate\Contracts\Encryption\StringEncrypter'); diff --git a/tests/Log/LogWriterTest.php b/tests/Log/LogWriterTest.php deleted file mode 100755 index 4c2ace42..00000000 --- a/tests/Log/LogWriterTest.php +++ /dev/null @@ -1,102 +0,0 @@ -shouldReceive('pushHandler')->once()->with(m::type(StreamHandler::class)); - $writer->useFiles(__DIR__); - } - - - public function testRotatingFileHandlerCanBeAdded() - { - $writer = new IlluminateLogger($monolog = m::mock(Logger::class)); - $monolog->shouldReceive('pushHandler')->once()->with(m::type(RotatingFileHandler::class)); - $writer->useDailyFiles(__DIR__, 5); - } - - - public function testErrorLogHandlerCanBeAdded() - { - $writer = new IlluminateLogger($monolog = m::mock(Logger::class)); - $monolog->shouldReceive('pushHandler')->once()->with(m::type(ErrorLogHandler::class)); - $writer->useErrorLog(); - } - - - public function testMagicMethodsPassErrorAdditionsToMonolog() - { - $writer = new IlluminateLogger($monolog = m::mock(Logger::class)); - $monolog->shouldReceive('log')->once()->with('error', 'foo', []); - - $writer->error('foo'); - } - - - public function testWriterFiresEventsDispatcher() - { - $writer = new IlluminateLogger($monolog = m::mock(Logger::class), $events = new Illuminate\Events\Dispatcher); - $monolog->shouldReceive('log')->once()->with('error', 'foo', []); - - $events->listen('illuminate.log', function($level, $message, array $context = []) - { - $_SERVER['__log.level'] = $level; - $_SERVER['__log.message'] = $message; - $_SERVER['__log.context'] = $context; - }); - - $writer->error('foo'); - $this->assertTrue(isset($_SERVER['__log.level'])); - $this->assertEquals('error', $_SERVER['__log.level']); - unset($_SERVER['__log.level']); - $this->assertTrue(isset($_SERVER['__log.message'])); - $this->assertEquals('foo', $_SERVER['__log.message']); - unset($_SERVER['__log.message']); - $this->assertTrue(isset($_SERVER['__log.context'])); - $this->assertEquals([], $_SERVER['__log.context']); - unset($_SERVER['__log.context']); - } - - - public function testListenShortcutFailsWithNoDispatcher() - { - $this->expectException(RuntimeException::class); - $writer = new IlluminateLogger($monolog = m::mock(Logger::class)); - $writer->listen( - function () { - } - ); - } - - - public function testListenShortcut() - { - $writer = new IlluminateLogger($monolog = m::mock(Logger::class), $events = m::mock( - Dispatcher::class - )); - - $callback = function() { return 'success'; }; - $events->shouldReceive('listen')->with('illuminate.log', $callback)->once(); - - $writer->listen($callback); - } - -}