From 3e65d5dc1f108ebe1dcb264bd20f8b61220bb86b Mon Sep 17 00:00:00 2001 From: Dat Tran Date: Wed, 8 Nov 2023 14:27:23 +0100 Subject: [PATCH 1/3] fix: sequenceToken is now ignored --- cloudwatch/cloudwatch.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/cloudwatch/cloudwatch.py b/cloudwatch/cloudwatch.py index 5a3a5bd..8bb3cbc 100644 --- a/cloudwatch/cloudwatch.py +++ b/cloudwatch/cloudwatch.py @@ -85,18 +85,9 @@ def __init__(self, def send_log(self, timestamp, log_entry): #Send the message to AWS (function depends if there is a token or not) - if self.next_sequence_token: - response = self.logs.put_log_events(logGroupName=self.log_group, + self.logs.put_log_events(logGroupName=self.log_group, logStreamName=self.log_stream, - sequenceToken = self.next_sequence_token, logEvents=[{'timestamp': timestamp,'message': log_entry}]) - else: - response = self.logs.put_log_events(logGroupName=self.log_group, - logStreamName=self.log_stream, - logEvents=[{'timestamp': timestamp,'message': log_entry}]) - - #Store the next token - self.next_sequence_token = response['nextSequenceToken'] def emit(self, record): """This is the overriden function from the handler to send logs to AWS From 78648244a08898ff0830cebc673a6a2c410871c2 Mon Sep 17 00:00:00 2001 From: Dat Tran Date: Wed, 8 Nov 2023 14:28:59 +0100 Subject: [PATCH 2/3] fix: add sequencetoken with empty string --- cloudwatch/cloudwatch.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cloudwatch/cloudwatch.py b/cloudwatch/cloudwatch.py index 8bb3cbc..9aed0a4 100644 --- a/cloudwatch/cloudwatch.py +++ b/cloudwatch/cloudwatch.py @@ -84,11 +84,13 @@ def __init__(self, logging.Handler.__init__(self) def send_log(self, timestamp, log_entry): - #Send the message to AWS (function depends if there is a token or not) + #Send the message to AWS self.logs.put_log_events(logGroupName=self.log_group, logStreamName=self.log_stream, + sequenceToken="", # ignored by PutLogEvents logEvents=[{'timestamp': timestamp,'message': log_entry}]) - + + def emit(self, record): """This is the overriden function from the handler to send logs to AWS """ From 5d20bb890da3ba559c2d96a9a213d28f9843818a Mon Sep 17 00:00:00 2001 From: Dat Tran Date: Wed, 8 Nov 2023 14:29:46 +0100 Subject: [PATCH 3/3] fix: formatting --- cloudwatch/cloudwatch.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cloudwatch/cloudwatch.py b/cloudwatch/cloudwatch.py index 9aed0a4..8457dcb 100644 --- a/cloudwatch/cloudwatch.py +++ b/cloudwatch/cloudwatch.py @@ -90,7 +90,6 @@ def send_log(self, timestamp, log_entry): sequenceToken="", # ignored by PutLogEvents logEvents=[{'timestamp': timestamp,'message': log_entry}]) - def emit(self, record): """This is the overriden function from the handler to send logs to AWS """