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

implement LoggedException in vsc.utils.exceptions module #160

Merged
merged 9 commits into from
Mar 18, 2015

Conversation

boegel
Copy link
Member

@boegel boegel commented Mar 11, 2015

implement idea for self-logging exception mentioned by @riccardomurri in easybuilders/easybuild-framework#1183

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)
Copy link
Member

Choose a reason for hiding this comment

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

4 lines please

@hpcugentbot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/vsc-base-pr-builder/235/
Test FAILed.

@boegel
Copy link
Member Author

boegel commented Mar 11, 2015

removed the Py2.4 tests

@boegel
Copy link
Member Author

boegel commented Mar 11, 2015

Jenkins: test this please

@hpcugentbot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/vsc-base-pr-builder/236/
Test PASSed.

@boegel
Copy link
Member Author

boegel commented Mar 11, 2015

@stdweird: remark fixed, was that the only one?

@hpcugentbot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/vsc-base-pr-builder/237/
Test PASSed.

logger = None
try:
# frame may be None, see https://docs.python.org/2/library/inspect.html#inspect.currentframe
if frame is None:
Copy link
Member

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)

@stdweird
Copy link
Member

some minor remarks added

if logger is None:
logger = fancylogger.getLogger()

logger.error(msg)
Copy link
Member

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)

@boegel
Copy link
Member Author

boegel commented Mar 13, 2015

@stdweird: remarks fixed

@hpcugentbot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/vsc-base-pr-builder/238/
Test PASSed.

@hpcugentbot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/vsc-base-pr-builder/239/
Test PASSed.

Constructor.
@param logger: logger to use
"""
super(LoggedException, self).__init__(msg)
Copy link
Member

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 😄 )

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 doubt there's anything, but it can't hurt to do the logging first, so changed.

@stdweird
Copy link
Member

@boegel one minor remark left.

@hpcugentbot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/vsc-base-pr-builder/240/
Test PASSed.

@hpcugentbot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/vsc-base-pr-builder/241/
Test PASSed.

@boegel
Copy link
Member Author

boegel commented Mar 15, 2015

@stdweird: remark fixed, pls recheck how LOGGING_METHOD is defined, I had to change that to redefine it in EasyBuild (to avoid an infinite (re)raise situation with log.error)

@stdweird
Copy link
Member

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):
Copy link
Member

Choose a reason for hiding this comment

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

support *args

Copy link
Member Author

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

@hpcugentbot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/vsc-base-pr-builder/242/
Test PASSed.

@boegel
Copy link
Member Author

boegel commented Mar 17, 2015

@stdweird: remarks fixed, should be good to go? clean approach for specifying logging method just based on name works out well in EasyBuild

@stdweird
Copy link
Member

@boegel ok, seems sufficient for EB so merging this in. nice work

stdweird added a commit that referenced this pull request Mar 18, 2015
implement LoggedException in vsc.utils.exceptions module
@stdweird stdweird merged commit 76664eb into hpcugent:master Mar 18, 2015
@boegel boegel deleted the loggedexception branch April 9, 2015 19:58
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

Successfully merging this pull request may close these issues.

3 participants