-
Notifications
You must be signed in to change notification settings - Fork 79
Emit multi-line logs with timestamps #92
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
Conversation
LGTM |
@@ -1027,6 +1046,7 @@ def test_log_error_invokeId_line_framed_log_sink(self): | |||
"testrequestId", | |||
) | |||
bootstrap.log_error(err_to_log, log_sink) | |||
after = int(time.time_ns() / 1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: adding randomness into unit tests is discouraged. In this particular case it should not cause losing determinism, so it's fine to leave if here
@@ -335,7 +335,8 @@ def __exit__(self, exc_type, exc_value, exc_tb): | |||
|
|||
def log(self, msg): | |||
encoded_msg = msg.encode("utf8") | |||
log_msg = self.frame_type + len(encoded_msg).to_bytes(4, "big") + encoded_msg | |||
timestamp = int(time.time_ns() / 1000) # UNIX timestamp in microseconds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using //
should be a cleaner way to show that it's not a type conversion
Description of changes:
Lambda accepts multi-line messages where the timestamp of the log emission is encoded in the log event header. This helps ordering the function emitted messages with regards to platform emitted messages, e.g. START, REPORT.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.