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
Improve log messages #96
Conversation
@pluegh First of thanks a lot for starting this pull request. I hope I will find some time over the weekend to have a more detailed look but I support the idea of replacing prints with logging. Out of curiosity: how would this help with eos? |
@fredRos EOS now pipes all log messages into a |
@@ -5,6 +5,9 @@ | |||
import numpy as np | |||
import scipy.linalg as linalg | |||
|
|||
import logging | |||
logger = logging.getLogger(__name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This creates sub loggers, with a name of pypmc.mix_adapt.hierarchical
, correct?
Is there an easy way to get to all loggers that belong to the pypmc
root logger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct.
Checking the logging documentation, I don't think it's designed such that you can get a list of all child loggers. Instead, you are supposed to configure the parent logger (pypmc
or pypmc.mix_adapt
). This has the advantage that child loggers, which are instantiated later also adhere to the parent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird, but apparently the recommended approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve, but I would like to have also @fredRos to approve, if possible.
- Add a deprecation notice for the optional `verbose` argument - Create `tools/util.py` to contain technical helpers such as the deprecation warning used in various submodules.
@fredRos merging now. Please holler if you find something untoward a-posterior 😄 |
@dvandyk Sorry, I was overwhelmed with work and family. I know |
This pull request changes the way printing status messages is handled.
print
functionality is replaced by thelogging
standard library.Messages that were wrapped with
if(verbose)
are logged as information, or as warnings otherwise.util.log_to_stdout
sets up a basic logging handler for easy standalone usage of pypmc.This function is called in
__init__.py
as a drop-in replacement of the current behaviour.Comments
E.g. to only log warnings and errors from PMC, use
logging.getLogger('pypmc.mix_adapt.pmc').setLevel(logging.WARNING)
.logging
when no log handler is specified, is to print warnings and errors to stderr.WIP
verbose
argument instead of removing the option (breaking change).The wiki page is a good place to document logging after the proposed changes are approved.
Solves #95