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

Add Logging #875

Merged
merged 17 commits into from Jun 28, 2022
Merged

Add Logging #875

merged 17 commits into from Jun 28, 2022

Conversation

guyer
Copy link
Member

@guyer guyer commented Jun 24, 2022

See also a tiny new mpilogging package.

@guyer guyer requested review from wd15 and tkphd June 24, 2022 14:44
@guyer guyer changed the title Logging Add Logging Jun 24, 2022
@wd15
Copy link
Contributor

wd15 commented Jun 27, 2022

mpilogging doesn't seem to be in pypi yet. Is it supposed to be?

documentation/USAGE.rst Outdated Show resolved Hide resolved
@guyer
Copy link
Member Author

guyer commented Jun 27, 2022

mpilogging doesn't seem to be in pypi yet. Is it supposed to be?

No. Bootstrapping issue. I'd like somebody else's impression before I transfer it to usnistgov, and I want to do that before it goes to PyPI, but it seems silly to write (hopefully) very temporary instructions about how to get it.

@guyer guyer requested a review from wd15 June 27, 2022 13:50
>>> logfile.setLevel(logging.DEBUG)
>>> log.addHandler(logfile)

>>> log.setLevel(logging.DEBUG)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to set the level twice?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a debatable point. One establishes what logging messages are captured by a particular handler; the other establishes what messages get generated at all.

@wd15
Copy link
Contributor

wd15 commented Jun 27, 2022

Would is make sense to include the version number of the dependencies at the start of the log file in debug mode(like for python setup.py test)?

@guyer
Copy link
Member Author

guyer commented Jun 27, 2022

Would is make sense to include the version number of the dependencies at the start of the log file in debug mode(like for python setup.py test)?

Do you not get something like

{'python': '3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:45:10) [Clang 12.0.1 ]', 'fipy': '3.4.2.1+50.g2f7bf56b1', 'numpy': '1.22.4', 'pysparse': 'not installed', 'scipy': '1.8.1', 'matplotlib': '3.5.2', 'mpi4py': '3.1.3', 'petsc4py': '3.17.1', 'pyamgx': 'not installed', 'PyTrilinos': 'not installed', 'mayavi': '4.7.4', 'gmsh': '4.10.2', 'solver': 'petsc'}

logged at the top of a run?

@wd15
Copy link
Contributor

wd15 commented Jun 27, 2022

Do you not get something like

{'python': '3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:45:10) [Clang 12.0.1 ]', 'fipy': '3.4.2.1+50.g2f7bf56b1', 'numpy': '1.22.4', 'pysparse': 'not installed', 'scipy': '1.8.1', 'matplotlib': '3.5.2', 'mpi4py': '3.1.3', 'petsc4py': '3.17.1', 'pyamgx': 'not installed', 'PyTrilinos': 'not installed', 'mayavi': '4.7.4', 'gmsh': '4.10.2', 'solver': 'petsc'}

logged at the top of a run?

Funny that you asked, but yes I do! I thought it was a good idea, but didn't think you would also have this good idea.

documentation/USAGE.rst Outdated Show resolved Hide resolved
fipy/__init__.py Outdated Show resolved Hide resolved
fipy/__init__.py Outdated Show resolved Hide resolved
fipy/__init__.py Outdated Show resolved Hide resolved

_log = logging.getLogger(__name__)

from ._version import get_versions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe at top of file

@wd15
Copy link
Contributor

wd15 commented Jun 27, 2022

FYI, there's a stray DEBUG=True here. Might be left over from the debug statements.

from fipy.tools.logging import package_info

_log.info(package_info())
del package_info
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you are deleting these modules hence why you're doing the import close by

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I guess it would be cleaner overall to do all the imports together and just make sure the namespace is clean at the end.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've collected most of the imports at top, but these are a little trickier. Any logging configuration should be in effect before doing anything that might cause logging.

Copy link
Contributor

@tkphd tkphd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think JSON is misdefined, but otherwise this LGTM.

documentation/glossary.rst Outdated Show resolved Hide resolved
@guyer guyer merged commit 052ede9 into usnistgov:master Jun 28, 2022
@guyer guyer deleted the logging branch June 28, 2022 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants