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

Bugs related to logger #256

Open
1 of 3 tasks
abhaasgoyal opened this issue Feb 29, 2024 · 3 comments
Open
1 of 3 tasks

Bugs related to logger #256

abhaasgoyal opened this issue Feb 29, 2024 · 3 comments
Labels
bug Something isn't working invalid This doesn't seem right priority:medium Medium priority issues to become high priority issues after a release.

Comments

@abhaasgoyal
Copy link

abhaasgoyal commented Feb 29, 2024

As of now, the logger is not being used properly in the codebase / has existing bugs.

Current issues

@abhaasgoyal abhaasgoyal added the invalid This doesn't seem right label Feb 29, 2024
@abhaasgoyal abhaasgoyal added the bug Something isn't working label Mar 1, 2024
@bschroeter
Copy link
Collaborator

OK, to provide some additional context here, I think we need to take a look at the code that redirects printing to standard out in subprocess.py.

-------
subprocess.CompletedProcess
_description_
"""
# Use the logging level (10 = Debug) to determine verbosity.
verbose = get_logger().getEffectiveLevel() == DEBUG_LEVEL
kwargs: Any = {}
with contextlib.ExitStack() as stack:
if capture_output:
kwargs["text"] = True
kwargs["stdout"] = subprocess.PIPE
elif output_file:
kwargs["stdout"] = stack.enter_context(
output_file.open("w", encoding="utf-8")
)
else:
kwargs["stdout"] = None if verbose else subprocess.DEVNULL
kwargs["stderr"] = subprocess.STDOUT
if env:

I think that we can basically remove the bits that do the standard out catches of print statements and fall back onto using the native subprocess functionality to capture output from commands.

Now that I have a better understanding of this issue, prefixing set -x && to the command is not the correct approach, particularly if we are doing a log.debug() immediately prior. We should be relying on the logger to output commands in verbose mode, and leave the subprocess module to do its thing. We get no additional benefit by printing out the statement inside the subprocess call.

@SeanBryan51 can probably provide additional context here, as I believe he is most suited to comment being the author of this chunk of code.

With these comments added, I am going to un-assign myself as I am working on other tasks and I'm not sure when I'll be available to work on this one - particularly if it becomes a blocker. @ccarouge, please feel free to re-assign me if needed. It isn't a great deal of work to address this issue.

@bschroeter bschroeter removed their assignment Mar 3, 2024
@SeanBryan51
Copy link
Collaborator

I think the redirection of subprocess output to stdout was done so that buffering the output wasn't required (this lets us see the output of subprocess commands in real time):

kwargs["stdout"] = None if verbose else subprocess.DEVNULL

If the intention is to redirect the subprocess output to the logger, this SO post might be relevant: https://stackoverflow.com/questions/21953835/run-subprocess-and-print-output-to-logging

I'm not too sure exactly what the context is for this issue so I'm not sure if this helps, @abhaasgoyal can you update the issue description?

@abhaasgoyal
Copy link
Author

@SeanBryan51 I have added the description for the issue. Let me know if anything's unclear.

@SeanBryan51 SeanBryan51 added the priority:medium Medium priority issues to become high priority issues after a release. label Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right priority:medium Medium priority issues to become high priority issues after a release.
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants