From ed8f752fe63e60d1b3c6e672543d734989f4037b Mon Sep 17 00:00:00 2001 From: Giacomo Leidi Date: Sat, 20 Nov 2021 15:53:38 +0100 Subject: [PATCH] Make logs a little bit more informative. (#100) --- mobilizon_reshare/main/start.py | 4 ++-- mobilizon_reshare/publishers/coordinator.py | 2 ++ mobilizon_reshare/storage/db.py | 8 -------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/mobilizon_reshare/main/start.py b/mobilizon_reshare/main/start.py index 5c9eac0..58941d4 100644 --- a/mobilizon_reshare/main/start.py +++ b/mobilizon_reshare/main/start.py @@ -44,7 +44,7 @@ async def start(): ) if event: - logger.debug(f"Event to publish found: {event.name}") + logger.info(f"Event to publish found: {event.name}") models = await create_event_publication_models(event) publications = list(EventPublication.from_orm(m, event) for m in models) @@ -55,4 +55,4 @@ async def start(): if not report.succesful: PublicationFailureNotifiersCoordinator(report,).notify_failure() else: - logger.debug("No event to publish found") + logger.info("No event to publish found") diff --git a/mobilizon_reshare/publishers/coordinator.py b/mobilizon_reshare/publishers/coordinator.py index a830f3e..f1b7b30 100644 --- a/mobilizon_reshare/publishers/coordinator.py +++ b/mobilizon_reshare/publishers/coordinator.py @@ -82,6 +82,7 @@ class PublisherCoordinator: for publication in self.publications: try: + logger.info(f"Publishing to {publication.publisher.name}") message = publication.formatter.get_message_from_event( publication.event ) @@ -94,6 +95,7 @@ class PublisherCoordinator: ) ) except PublisherError as e: + logger.error(str(e)) reports.append( EventPublicationReport( status=PublicationStatus.FAILED, diff --git a/mobilizon_reshare/storage/db.py b/mobilizon_reshare/storage/db.py index 7f0b289..0374f60 100644 --- a/mobilizon_reshare/storage/db.py +++ b/mobilizon_reshare/storage/db.py @@ -41,13 +41,5 @@ class MoReDB: await update_publishers(publisher_names) -@atexit.register -def gracefully_tear_down(): - logger.info("Shutting down DB") - loop = asyncio.new_event_loop() - asyncio.set_event_loop(loop) - asyncio.run(tear_down()) - - async def tear_down(): return await Tortoise.close_connections()