Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ Config for logging is defined at `config/logging.php`. Add `cloudwatch` to the `
'group_name' => env('CLOUDWATCH_LOG_GROUP_NAME', 'laravel_app'),
'version' => env('CLOUDWATCH_LOG_VERSION', 'latest'),
'formatter' => \Monolog\Formatter\JsonFormatter::class,
'batch_size' => env('CLOUDWATCH_LOG_BATCH_SIZE', 10000),
'batch_size' => env('CLOUDWATCH_LOG_BATCH_SIZE', 10000),
'create_group' => env('CLOUDWATCH_CREATE_GROUP', true)
'via' => \Pagevamp\Logger::class,
],
]
Expand All @@ -51,6 +52,10 @@ And set the `LOG_CHANNEL` in your environment variable to `cloudwatch`.

If the role of your AWS EC2 instance has access to Cloudwatch logs, `CLOUDWATCH_LOG_KEY` and `CLOUDWATCH_LOG_SECRET` need not be defined in your `.env` file.

### AWS IAM permissions

The needed permissions can be found [here](https://github.com/maxbanton/cwh#aws-iam-needed-permissions).

### Contribution

I have added a `pre-commit` hook to run `php-cs-fixer` whenever you make a commit. To enable this run `sh hooks.sh`.
Expand Down
4 changes: 3 additions & 1 deletion src/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Pagevamp;

use Monolog\Logger as MonoLogger;
use Aws\CloudWatchLogs\CloudWatchLogsClient;
use PhpNexus\Cwh\Handler\CloudWatch;
use Monolog\Formatter\LineFormatter;
Expand Down Expand Up @@ -29,9 +30,10 @@ public function __invoke(array $config)
$streamName = $loggingConfig['stream_name'];
$retentionDays = $loggingConfig['retention'];
$groupName = $loggingConfig['group_name'];
$createGroup = isset($loggingConfig['create_group']) ? $loggingConfig['create_group'] : true;
$batchSize = isset($loggingConfig['batch_size']) ? $loggingConfig['batch_size'] : 10000;

$logHandler = new CloudWatch($cwClient, $groupName, $streamName, $retentionDays, $batchSize);
$logHandler = new CloudWatch($cwClient, $groupName, $streamName, $retentionDays, $batchSize, [], MonoLogger::DEBUG, true, $createGroup);
$logger = new \Monolog\Logger($loggingConfig['name']);

$formatter = $this->resolveFormatter($loggingConfig);
Expand Down