1
Fork 0
mirror of https://github.com/Steffo99/unimore-bda-6.git synced 2024-11-25 17:24:20 +00:00

Improve logging

This commit is contained in:
Steffo 2023-02-02 17:46:21 +01:00
parent 965cea692a
commit 767a6087a8
Signed by: steffo
GPG key ID: 2A24051445686895

View file

@ -30,15 +30,15 @@ def mongo_client_from_config() -> t.ContextManager[pymongo.MongoClient]:
Create a new MongoDB client and yield it. Create a new MongoDB client and yield it.
""" """
log.debug("Opening connection to MongoDB...") log.debug("Opening connection to MongoDB...")
client = pymongo.MongoClient( client: pymongo.MongoClient = pymongo.MongoClient(
host=MONGO_HOST.__wrapped__, host=MONGO_HOST.__wrapped__,
port=MONGO_PORT.__wrapped__, port=MONGO_PORT.__wrapped__,
) )
log.info("Opened connection to MongoDB: %s", client) log.info("Opened connection to MongoDB at %s!", client.address)
yield client yield client
log.info("Closing connection to MongoDB: %s", client) log.info("Closing connection to MongoDB...")
client.close() client.close()
log.debug("Closed connection to MongoDB!") log.debug("Closed connection to MongoDB!")