Skip to content

Commit 2e259b8

Browse files
PeteBishwhipPete Bishop
authored andcommitted
[12.x] Ensure laravel-cloud-socket respects LOG_LEVEL (laravel#57071)
* Add log level to laravel-cloud-socket configuration * Add test to ensure log levels are respected --------- Co-authored-by: Pete Bishop <[email protected]>
1 parent 0ff9e14 commit 2e259b8

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/Illuminate/Foundation/Cloud.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ public static function configureCloudLogging(Application $app): void
123123

124124
$app['config']->set('logging.channels.laravel-cloud-socket', [
125125
'driver' => 'monolog',
126+
'level' => $_ENV['LOG_LEVEL'] ??
127+
$_SERVER['LOG_LEVEL'] ??
128+
'debug',
126129
'handler' => SocketHandler::class,
127130
'formatter' => JsonFormatter::class,
128131
'formatter_with' => [

tests/Integration/Foundation/CloudTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,23 @@ public function test_it_can_configure_disks()
5252

5353
unset($_SERVER['LARAVEL_CLOUD_DISK_CONFIG']);
5454
}
55+
56+
public function test_it_respects_log_levels()
57+
{
58+
if (isset($_SERVER['LOG_LEVEL'])) {
59+
$logLevelBackup = $_SERVER['LOG_LEVEL'];
60+
}
61+
62+
$_SERVER['LOG_LEVEL'] = 'notice';
63+
64+
Cloud::configureCloudLogging($this->app);
65+
66+
$this->assertEquals('notice', $this->app['config']->get('logging.channels.laravel-cloud-socket.level'));
67+
68+
unset($_SERVER['LOG_LEVEL']);
69+
70+
if (isset($logLevelBackup)) {
71+
$_SERVER['LOG_LEVEL'] = $logLevelBackup;
72+
}
73+
}
5574
}

0 commit comments

Comments
 (0)