aws / aws-lambda-builders

Python library to compile, build & package AWS Lambda functions for several runtimes & framework
Apache License 2.0
334 stars 139 forks source link

fix: Fix missing encoding when logging from Makefile #535

Closed lucashuy closed 1 year ago

lucashuy commented 1 year ago

Issue #, if available: N/A

Description of changes: Some of the output that may come from a Makefile (eg. Terraform output) can contain some colour and encoding information (eg. b'\x1b[0m\x1b[1mInitializing provider plugins...\x1b[0m\n'). This does not get logged properly in the terminal.

Changes are to use sys.stderr.buffer.write() to print these messages instead.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

lucashuy commented 1 year ago

Good call out, Terraform output includes this newline however other outputs from commands may not. Will look into it

From: Daniel Mil @.> Reply-To: aws/aws-lambda-builders @.> Date: Tuesday, August 29, 2023 at 2:31 PM To: aws/aws-lambda-builders @.> Cc: "Huynh, Lucas" @.>, Author @.***> Subject: Re: [aws/aws-lambda-builders] fix: Fix missing encoding when logging from Makefile (PR #535)

@mildaniel commented on this pull request.


In aws_lambda_builders/workflows/custom_make/make.pyhttps://github.com/aws/aws-lambda-builders/pull/535#discussion_r1309374488:

@@ -92,9 +93,11 @@ def run(self, args, env=None, cwd=None):

     # Log every stdout line by iterating

     for line in p.stdout:

AFAIK, sys.stderr.buffer.write won't include a newline at the end of the string which might make the next log statement messy. Should we add a newline after?

— Reply to this email directly, view it on GitHubhttps://github.com/aws/aws-lambda-builders/pull/535#pullrequestreview-1601312145, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC7K2P4JTL2SMVBLOIQTTWLXXZNQRANCNFSM6AAAAAA4DMTRJU. You are receiving this because you authored the thread.Message ID: @.***>