Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep "nextSequenceToken" from "put_log_events" API call #177

Closed
wants to merge 1 commit into from
Closed
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 source/code/util/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def get_loggroup(lambda_context):
self._debug = debug
self._cached_size = 0
self._client = None
self._next_sequence_token = None
self._loggroup = loggroup if loggroup is not None else get_loggroup(self._context)

self._sns = None
Expand Down Expand Up @@ -193,6 +194,9 @@ def flush(self):

def get_next_log_token():

if self._next_sequence_token:
return self._next_sequence_token

resp = self.client.describe_log_streams_with_retries(logGroupName=self._loggroup, logStreamNamePrefix=self._logstream)
if "logStreams" in resp and len(resp["logStreams"]) > 0:
token = resp["logStreams"][0].get("uploadSequenceToken")
Expand Down Expand Up @@ -233,7 +237,8 @@ def get_next_log_token():
if next_token is not None:
put_event_args["sequenceToken"] = next_token
try:
self.client.put_log_events(**put_event_args)
r = self.client.put_log_events(**put_event_args)
self._next_sequence_token = r['nextSequenceToken']
self._buffer = []
self._cached_size = 0
return
Expand Down