maxbanton / cwh

Amazon Web Services CloudWatch Logs Handler for Monolog library
MIT License
417 stars 84 forks source link

#116 monolog update #117

Open tanerincode opened 1 year ago

tanerincode commented 1 year ago

Monologue has made a significant change, it now accepts LogRecords instead of arrays. This PR contains minor changes for the given situation.

        $config = [
            "group_name" => "my_group_name",
            "stream_name" => "my_stream_name",
            "retention" => 30,
            "sdk" => [
                  'region' => 'eu-east-1',
                  'version' => 'latest',
                  'credentials' => [
                      'key' => getenv('AWS_CLOUDWATCH_KEY'),
                      'secret' => getenv('AWS_CLOUDWATCH_SECRET')
                  ]
            ]
        ];

      $client = new CloudWatchLogsClient($config["sdk"]);

       $handler = new CloudWatch(
            client: $client,
            group: $config["group_name"],
            stream: $config["stream_name"],
            retention: $config["retention"],
            batchSize: 10000,
            tags: [], 
            level: Level::Debug, 
            bubble: true,
            createGroup: false
        );

        $handler->setFormatter(new JsonFormatter());
        $logger = new Logger('here_your_channel_name');
        $logger->pushHandler($handler);

        return $logger;
vnrmc commented 1 year ago

Great job, tanerincode! I hope Maksym finds time to approve it :)

stefanrakicfaxi commented 1 year ago

@maxbanton please approve this PR if it's okay for you

ravewill commented 1 year ago

I'm switching to another CloudWatch logging provider as this is blocking my upgrade to Laravel 10. I'm sure I'm not alone :disappointed:

SoCooLoveec commented 1 year ago

@maxbanton can you please merge this PR and make new release version?

jandominikair commented 10 months ago

@maxbanton Please, do you have any update to merge this PR?

tanerincode commented 10 months ago

@jandominikair i think he is not available for review this pr, someone did this package alternative with this fix, you can find that one in pr's or issues