From 1e2faa0872fb2e1f90eb9f5b8e4e3260e6d6edd5 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 19 May 2024 07:17:44 +0800 Subject: [PATCH] Laravel Vapor - Look into logs in different channel in cloudwatch --- app/Classes/General/LogHelper.php | 3 +-- app/Logging/CloudWatchLoggerFactory.php | 2 +- config/logging.php | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Classes/General/LogHelper.php b/app/Classes/General/LogHelper.php index 73923631..0c769276 100644 --- a/app/Classes/General/LogHelper.php +++ b/app/Classes/General/LogHelper.php @@ -17,8 +17,7 @@ class LogHelper public function info($message) { - $channelName = $this->channelName; - Log::info("LogHelper message: {$message}, channelName: {$channelName}"); + Log::info("LogHelper message: {$message}, channelName: {$this->channelName}"); if(env('LARAVEL_VAPOR_ENABLED')){ Log::channel($this->channelName.'_vapor')->info($message); } diff --git a/app/Logging/CloudWatchLoggerFactory.php b/app/Logging/CloudWatchLoggerFactory.php index 863dfa55..c0c50928 100644 --- a/app/Logging/CloudWatchLoggerFactory.php +++ b/app/Logging/CloudWatchLoggerFactory.php @@ -25,7 +25,7 @@ class CloudWatchLoggerFactory $client = new CloudWatchLogsClient($sdkParams); // Log group name, will be created if none - $groupName = config('app.name') . '-' . config('app.env'); + $groupName = $config["groupNamePrefix"] . '-' . $config["groupNameSuffix"]; // Log stream name, will be created if none // $streamName = config('app.hostname'); diff --git a/config/logging.php b/config/logging.php index 7191f30a..f4703ffa 100644 --- a/config/logging.php +++ b/config/logging.php @@ -75,6 +75,8 @@ return [ ], 'retention' => 3, //cief todo: to be updated 'level' => 'debug', + 'groupNamePrefix' => env('CLOUDWATCH_LOGGROUP_PREFIX'), + 'groupNameSuffix' => env('CLOUDWATCH_LOGGROUP_SUFFIX'), ], 'slack' => [