Jayich-Lab / tray-launcher

A launcher for Windows that resides in the taskbar for managing .bat scripts.
MIT License
7 stars 1 forks source link

Couldn't properly write stdout to a log file #38

Closed danhuaxu closed 2 years ago

danhuaxu commented 2 years ago

stderr worked, partially - I raised an OSError and there were error messages in the log file. But when I did print(..., file=stderr), this didn't print to the file.

stdout failed - I had to explicitly add a line sys.stdout.flush() to get the output into the log file.

This seems like a problem back to earlier versions of tray launcher. I haven't tested on all 0.1.x versions, but 0.1.4 certainly had this issue.

fanmingyu212 commented 2 years ago

More details could be helpful here. Is this referring to print statements in the tray launcher itself or scripts it runs?

I think the tray launcher itself should not use print typically. I think it should use the logging module.

danhuaxu commented 2 years ago

I am referring to print in scripts it runs.

Yes, the tray launcher itself is using logging to record things.

fanmingyu212 commented 2 years ago

I see. I am not sure if there is an easy solution to this problem. This is likely not an very important thing to solve now - the idea of tray launcher is that the user does not need to look at the terminal (and print statements). Therefore, as long as all prints and errors are saved in the log file when the script exits, which I think is the behavior now, I think this is not an issue for us.

danhuaxu commented 2 years ago

Sounds good. Should I close this issue then?

fanmingyu212 commented 2 years ago

Yes I think you can close this.