You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to figure out how to get the stdout text that was written through the python logging library while running a pyscript.
I have the following simple pyscript (test_script.py):
print("*** About to do push-ups...")
result = app("do_with_logger push-ups")
print("*** RESULT: " + str(result))
print("*** About to do sit-ups...")
result = app("do_with_print sit-ups")
print("*** RESULT: " + str(result))
app("quit")
Running through the following simple shell (main.py):
If I run the pyscript with python3 main.py "run_pyscript test_script.py", I get:
*** About to do push-ups...
INFO:customlogger:doing push-ups ...
*** RESULT: CommandResult(stdout='', stderr=None, stop=False, data=None)
*** About to do sit-ups...
*** RESULT: CommandResult(stdout='doing sit-ups ...\n', stderr=None, stop=False, data=None)
You can see that the logger appeared to write to stdout but the CommandResult did not capture it, whereas the print() wrote to stdout and it was captured in the CommandResult.
The main reason that I'm using the logging library is to be able to easily control the verbosity and amount of data that I get for each command.
Activity
csonsino commentedon May 5, 2021
I just noticed the "Discussions" feature - let me know if you want me to move this over there instead of an Issue.