Skip to content
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

Use logging instead of prints #865

Open
paskino opened this issue May 27, 2021 · 1 comment
Open

Use logging instead of prints #865

paskino opened this issue May 27, 2021 · 1 comment

Comments

@paskino
Copy link
Contributor

paskino commented May 27, 2021

https://docs.python.org/3/library/logging.html

@paskino paskino added this to the version 21.3 milestone May 27, 2021
@gfardell gfardell modified the milestones: version 21.3, Future Version Sep 10, 2021
@gfardell
Copy link
Member

gfardell commented Feb 2, 2022

If you create logger inside a module with the module name:

import logging
logger = logging.getLogger(__name__)

then output statements as:

logger.info('setting up CGLS')
logger.warning('xinit is deprecated')

we can then have users change the verbosity level they want, the start of the script needs something like:

import logging
logging.basicConfig(level=logging.WARNING)
cil_log_level = logging.getLogger('cil.optimisation.algorithms.CGLS')
cil_log_level.setLevel(logging.DEBUG)

Or the module structure of the names means you can target all the loggers you want at each module level:

logging.basicConfig(level=logging.WARNING)
cil_log_level = logging.getLogger('cil')
cil_log_level.setLevel(logging.INFO)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants