-
Notifications
You must be signed in to change notification settings - Fork 51
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
implement LoggedException in vsc.utils.exceptions module #160
Conversation
logger = None | ||
try: | ||
# frame may be None, see https://docs.python.org/2/library/inspect.html#inspect.currentframe | ||
framerecords = (frame is None and []) or inspect.getouterframes(frame) |
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.
4 lines please
Refer to this link for build results (access rights to CI server needed): |
removed the Py2.4 tests |
Jenkins: test this please |
Refer to this link for build results (access rights to CI server needed): |
@stdweird: remark fixed, was that the only one? |
Refer to this link for build results (access rights to CI server needed): |
logger = None | ||
try: | ||
# frame may be None, see https://docs.python.org/2/library/inspect.html#inspect.currentframe | ||
if frame is None: |
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.
the whole try/finally
blck is part of the else (or rather the if is not None
)
some minor remarks added |
if logger is None: | ||
logger = fancylogger.getLogger() | ||
|
||
logger.error(msg) |
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.
also the log function should be configurable with class constant (probably needed in EB)
@stdweird: remarks fixed |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Constructor. | ||
@param logger: logger to use | ||
""" | ||
super(LoggedException, self).__init__(msg) |
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 there anything in the __init__
that could cause the logging part below not to be reached? (i guess only a raise
in the __init__
can cause that?)
to be safe, i'd move the super
after the logging block (then there's always logging).
(maybe this is a bit farfetched 😄 )
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 doubt there's anything, but it can't hurt to do the logging first, so changed.
@boegel one minor remark left. |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
@stdweird: remark fixed, pls recheck how |
what do you do now in EB? |
# note: 'self' (LoggedException instance) is passed as 1st argument, which is typically just ignored | ||
LOGGING_METHOD = lambda _, logger, msg: logger.error(msg) | ||
|
||
def __init__(self, msg, logger=None): |
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.
support *args
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.
ok, I'll tackle that
Refer to this link for build results (access rights to CI server needed): |
@stdweird: remarks fixed, should be good to go? clean approach for specifying logging method just based on name works out well in EasyBuild |
@boegel ok, seems sufficient for EB so merging this in. nice work |
implement LoggedException in vsc.utils.exceptions module
implement idea for self-logging exception mentioned by @riccardomurri in easybuilders/easybuild-framework#1183