-
Notifications
You must be signed in to change notification settings - Fork 148
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
Add Logging #875
Changes from 13 commits
8e83c73
ae10871
487b692
9199837
2558e6f
b975d13
405ad84
739d747
f3555bd
fb3ca02
388f0ea
cd8757f
2f7bf56
a21d146
9868ba8
ca1efdc
9514483
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -365,6 +365,7 @@ Zhitenev | |
3D | ||
3x2x1 | ||
- | ||
-formatted | ||
-only | ||
-periodicity | ||
-valued | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,8 +35,37 @@ | |
from builtins import input | ||
__docformat__ = 'restructuredtext' | ||
|
||
import os | ||
|
||
# configure logging before doing anything else, otherwise we'll miss things | ||
if 'FIPY_LOG_CONFIG' in os.environ: | ||
import json | ||
guyer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import logging.config | ||
guyer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
with open(os.environ['FIPY_LOG_CONFIG'], mode='r') as fp: | ||
logging.config.dictConfig(json.load(fp)) | ||
|
||
import logging | ||
guyer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
_log = logging.getLogger(__name__) | ||
|
||
from ._version import get_versions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe at top of file |
||
__version__ = get_versions()['version'] | ||
del get_versions | ||
|
||
import sys | ||
|
||
# log uncaught exceptions | ||
def excepthook(*args): | ||
_log.error('Uncaught exception:', exc_info=args) | ||
|
||
sys.excepthook = excepthook | ||
|
||
from fipy.tools.logging import package_info | ||
|
||
_log.info(package_info()) | ||
del package_info | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
|
||
from fipy.boundaryConditions import * | ||
from fipy.meshes import * | ||
from fipy.solvers import * | ||
|
@@ -143,7 +172,3 @@ def test(*args): | |
import shutil | ||
shutil.rmtree(tmpDir) | ||
raise exitErr | ||
|
||
from ._version import get_versions | ||
__version__ = get_versions()['version'] | ||
del get_versions |
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.
Is it necessary to set the level twice?
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.
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.