• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / relman-auto-nag / #4084

pending completion
#4084

push

coveralls-python

web-flow
Log uncaught exceptions (#1848)

549 of 3073 branches covered (17.87%)

5 of 5 new or added lines in 1 file covered. (100.0%)

1775 of 7951 relevant lines covered (22.32%)

0.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/auto_nag/__init__.py
1
# This Source Code Form is subject to the terms of the Mozilla Public
2
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
# You can obtain one at http://mozilla.org/MPL/2.0/.
4

5
import logging
1✔
6
import sys
1✔
7

8
from . import config
1✔
9

10
config.load()
1✔
11

12
# We can remove this hack and load utils in the same line as config when we fix
13
# the libmozdata bug that doesn't allow to reset the configuration.
14
try:
1✔
15
    from . import utils
1✔
16
except ModuleNotFoundError:
×
17
    raise
×
18

19

20
VERSION = (0, 0, 1)
1✔
21
__version__ = ".".join(map(str, VERSION))
1✔
22

23

24
path = utils.get_config("common", "log")
1✔
25

26
logger = logging.getLogger()
1✔
27
logger.setLevel(logging.INFO)
1✔
28
handler = logging.StreamHandler(sys.stdout)
1✔
29
formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
1✔
30
handler.setFormatter(formatter)
1✔
31
logger.addHandler(handler)
1✔
32

33
error = logging.FileHandler(path)
1✔
34
error.setLevel(logging.ERROR)
1✔
35
error.setFormatter(formatter)
1✔
36
logger.addHandler(error)
1✔
37

38

39
def _handle_uncaught_exception(exc_type, exc_value, exc_traceback):
1✔
40
    if issubclass(exc_type, KeyboardInterrupt):
×
41
        sys.__excepthook__(exc_type, exc_value, exc_traceback)
×
42
    else:
43
        logger.critical(
×
44
            "Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback)
45
        )
46

47

48
sys.excepthook = _handle_uncaught_exception
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc