Skip to content

Commit e2a7f29

Browse files
committed
set cloud channel if not already defined by user
1 parent aa45498 commit e2a7f29

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

src/Illuminate/Foundation/Cloud.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public static function configureCloudLogging(Application $app): void
186186
'includeStacktraces' => true,
187187
]);
188188

189-
$app['config']->set('logging.channels.laravel-cloud-socket', [
189+
$channel = [
190190
'driver' => 'monolog',
191191
'level' => $_ENV['LOG_LEVEL'] ?? $_SERVER['LOG_LEVEL'] ?? 'debug',
192192
'handler' => SocketHandler::class,
@@ -198,7 +198,13 @@ public static function configureCloudLogging(Application $app): void
198198
'connectionString' => Cloud::socket(),
199199
'persistent' => true,
200200
],
201-
]);
201+
];
202+
203+
$app['config']->set('logging.channels.laravel-cloud-socket', $channel);
204+
205+
if (! $app['config']->has('logging.channels.cloud')) {
206+
$app['config']->set('logging.channels.cloud', $channel);
207+
}
202208
}
203209

204210
/**

tests/Integration/Foundation/CloudTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,29 @@ public function test_it_respects_log_levels()
100100
$_SERVER['LOG_LEVEL'] = $logLevelBackup;
101101
}
102102
}
103+
104+
public function test_it_aliases_cloud_logging_channel()
105+
{
106+
Cloud::configureCloudLogging($this->app);
107+
108+
$this->assertSame(
109+
$this->app['config']->get('logging.channels.laravel-cloud-socket'),
110+
$this->app['config']->get('logging.channels.cloud')
111+
);
112+
}
113+
114+
public function test_it_does_not_replace_existing_cloud_logging_channel()
115+
{
116+
$this->app['config']->set('logging.channels.cloud', [
117+
'driver' => 'single',
118+
'path' => 'test.log',
119+
]);
120+
121+
Cloud::configureCloudLogging($this->app);
122+
123+
$this->assertSame([
124+
'driver' => 'single',
125+
'path' => 'test.log',
126+
], $this->app['config']->get('logging.channels.cloud'));
127+
}
103128
}

0 commit comments

Comments
 (0)