-
Notifications
You must be signed in to change notification settings - Fork 245
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
Discussion: Update logging to allow end-user logging level #784
Comments
Thanks for this. Yes, please open a pull request and I'll make tweaks if needed. I'm aware of the recommendation to not use the root logger, but I was unable to find a combination of settings that achieved what I wanted while still including error messages from other libraries. |
Before I open a PR, what is the use case for these logs? Are you looking for these logs to be generated while using the app in the GUI mode or are you intending this to be done when other people use kilosort in library mode (as demonstrated in my examples)? |
The same log needs to be generated whether run through the GUI or using the API. |
Since the GUI could have some GUI related errors that don't appear in the API version of the code, should those also be logged in the If they are meant to be in the same log file, then based off the structure, I'd suggest refactoring the code to remove the So then each file would have near the import statements import logging
logger = logging.getLogger(__name__) and the gui.py would then define the log handlers. I'll get around to making a first draft for this PR next week. How long do the integration tests take to run? I am curious if they would be a good place to test the logging as part of development. |
On reflection, could you specify what you wanted you wanted to achieve in terms of logging at a high level? Knowing what you were looking to achieve would help me for the PR. |
As for GUI-specific errors, it would be most convenient if they go in the same log, but they could also go in a separate log if it makes things difficult. GUI errors are usually much easier for me to debug, so I'm not as worried about that. The tests are fairly quick on GPU, they just take 1-2 minutes for me (or ~10 seconds if you skip the full pipeline test). You just have to make sure to add the appropriate flags. If you're adding some separate tests that only interact with logging, you probably don't need the full pipeline. So you could do The general goals with logging were:
|
So I've played around with trying to get all the requirements working and believe I have been able to get something that addresses most of the points without using the I have been able to address the double traceback to the console. By attaching the console to the root logger only and setting the kilosort logger to propagate, you can get all the messages written to the console as well as the file while handling the different logging levels as we had talked about before. If we leave the propagate as True during the What are your thoughts on this workaround to prevent the double console? If you would like, I can share the test repo that I've been using to address/test the different logging configurations. |
Are you saying we would change every
If so, I would rather not use that work-around. It adds a lot of extra mess to the code, and either myself or future devs will likely forget to do that for log statements that get added later which could get confusing. I think having double tracebacks is preferable to that. |
Hi Jacob. Since the double output only occurs when the program (A) logs the exception, (B) raises the error that then (C) is not handled by the user/program that called the function that raised the error. This occurs in only two places Here is an example repo that seems to tick all the boxes specified above. I haven't written up the GUI logger yet. It seems that it is doable using a combination of the logging cookbook and this video (around 13 minutes) that explains how to use your own class in the logger. |
Sorry for the delayed response, I've been busy working on other problems. Yes, that looks like it does what it would need to do. |
Sorry for my delayed response Jacob. I am glad you like the idea. I'll try to implement it later this week or next week. |
Feature you'd like to see:
Current Situation
In
run_kilosort.py
,setup_logger
defines the root logger vialogging.basicConfig()
. Python's logging guide suggests that the loggers typically be configured by the end user and not by libraries themselvs (relevant snippets posted below).Information Seeking/Understanding
Kilosort's interactions with external loggers
I've been able to generate small tests that can demonstrate the ability for kilosort4 to still log to its file handler while allowing the end user to control the root logger and other logging features.
setup_logger
function inrun_kilosort()
.) Notice the repeated log entries and spill from the outer_logger intokilosort4.log
kilosort4.log
Relevant snippets from Logging Guide
Additional Context
https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library
The text was updated successfully, but these errors were encountered: