Skip to content

Commit

Permalink
add a default message handler
Browse files Browse the repository at this point in the history
alternative to OFFIS-DAI/mango#144
  • Loading branch information
maurerle committed Dec 5, 2024
1 parent 44fb0fc commit 69cbb6c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion assume/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,16 @@
stdout_handler = logging.StreamHandler(stream=sys.stdout)
handlers = [file_handler, stdout_handler]
logging.basicConfig(level=logging.INFO, handlers=handlers)
logging.getLogger("mango").setLevel(logging.WARNING)
logging.getLogger("mango").setLevel(logging.ERROR)

logger = logging.getLogger(__name__)


def handle_exception(loop, context):
# context["message"] will always be there; but context["exception"] may not
msg = context.get("exception", context["message"])
logger.exception(f"Caught exception: {msg}")

Check warning on line 55 in assume/world.py

View check run for this annotation

Codecov / codecov/patch

assume/world.py#L54-L55

Added lines #L54 - L55 were not covered by tests

class World:
"""
World instance with the provided address, database URI, export CSV path, log level, and distributed role settings.
Expand Down Expand Up @@ -150,6 +155,7 @@ def __init__(
nest_asyncio.apply()
self.loop = asyncio.new_event_loop()
asyncio.set_event_loop(self.loop)
self.loop.set_exception_handler(handle_exception)

def setup(
self,
Expand Down

0 comments on commit 69cbb6c

Please sign in to comment.