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
Rich's logging handler produces an inline logging line in VSCode notebooks when the logging should be redirected to a file, and this file never gets writen.
I ran into the same problem in a plain notebook (well, jupyter lab). As a work around if you set the following in Console it works as expected:
Console(file=Path("test.log").open("w", encoding="utf_8"),
force_jupyter=False,
force_terminal=False, # this is needed because jupyter sets 'force_color' env var
)
The bug is that the jupyter notebook detection has a higher priority than a specified file.
There needs to be something to catch it in these locations but I'm not certain on the best implementation:
# return False for Jupyter, which may have FORCE_COLOR set
returnFalse
# If FORCE_COLOR env var has any value at all, we assume a terminal.
force_color=self._environ.get("FORCE_COLOR")
The first and second snippet is avoided by force_jupyter=False but this leads to the file having ANSI code sequences in the output which is off by default therefore force_terminal=False avoids the detection issue in the third snippet. If I come up with a nice solution i'll open a PR.
Rich's logging handler produces an inline logging line in VSCode notebooks when the logging should be redirected to a file, and this file never gets writen.
This code produces a duplicate logging and the file "test.log" remins empty.

Everything works fine when running from terminal.
Platform
Click to expand
The text was updated successfully, but these errors were encountered: