Skip to content

Commit 1936b9c

Browse files
authored
python: do not override root logger (#7743)
By adding a handler for `""`, we were effectively pushing all logs to a file, including the user's. I've removed the root logger and instead added a few other handlers to capture logs. **_This change does expose us to a much higher likelihood of our logs leaking into the console._** Eg, the added handlers were after observing `positron._vendor.pygls.protocol.json_rpc` will send out logs if you run something like `import xyzabc`, and the `Comm` logs were leaking if there is an error in the comms. Related issue in Jupyter, where they needed to handle `tornado` logs jupyter/notebook#1397 ### Release Notes <!-- Optionally, replace `N/A` with text to be included in the next release notes. The `N/A` bullets are ignored. If you refer to one or more Positron issues, these issues are used to collect information about the feature or bugfix, such as the relevant language pack as determined by Github labels of type `lang: `. The note will automatically be tagged with the language. These notes are typically filled by the Positron team. If you are an external contributor, you may ignore this section. --> #### New Features - N/A #### Bug Fixes - #4182 Python users' logs are now sent to console. ### QA Notes ```python import logging logging.warning("should show") ``` it's worth it to try to force a few other errors, to make sure we don't need to add other handlers.
1 parent 74fd52a commit 1936b9c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

extensions/positron-python/python_files/posit/positron_language_server.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,15 @@ def parse_args() -> argparse.Namespace:
9090
handlers = ["console"] if args.logfile is None else ["file"]
9191
logging_config = {
9292
"loggers": {
93-
"": {
93+
"PositronIPKernelApp": {
9494
"level": args.loglevel,
9595
"handlers": handlers,
9696
},
97-
"PositronIPKernelApp": {
97+
"Comm": {
98+
"level": args.loglevel,
99+
"handlers": handlers,
100+
},
101+
"positron": {
98102
"level": args.loglevel,
99103
"handlers": handlers,
100104
},

0 commit comments

Comments
 (0)