Logging with loguru (#708)

* logging

* requirements

* add loguru dependency

* restore it

* add loguru

* set log level in .env file

* remove service fee print

* set log level

* more logging

* more logging

* more logging

* pyament.checking_id

* fix
This commit is contained in:
calle
2022-07-07 14:30:16 +02:00
committed by GitHub
parent 847fd18796
commit 089313f613
40 changed files with 202 additions and 81 deletions
+7 -4
View File
@@ -4,6 +4,8 @@ import traceback
from http import HTTPStatus
from typing import List, Callable
from loguru import logger
from fastapi.exceptions import HTTPException
from lnbits.settings import WALLET
@@ -37,9 +39,9 @@ async def catch_everything_and_restart(func):
except asyncio.CancelledError:
raise # because we must pass this up
except Exception as exc:
print("caught exception in background task:", exc)
print(traceback.format_exc())
print("will restart the task in 5 seconds.")
logger.error("caught exception in background task:", exc)
logger.error(traceback.format_exc())
logger.error("will restart the task in 5 seconds.")
await asyncio.sleep(5)
await catch_everything_and_restart(func)
@@ -77,7 +79,7 @@ async def internal_invoice_listener():
async def invoice_listener():
async for checking_id in WALLET.paid_invoices_stream():
print("> got a payment notification", checking_id)
logger.info("> got a payment notification", checking_id)
asyncio.create_task(invoice_callback_dispatcher(checking_id))
@@ -117,6 +119,7 @@ async def perform_balance_checks():
async def invoice_callback_dispatcher(checking_id: str):
payment = await get_standalone_payment(checking_id, incoming=True)
if payment and payment.is_in:
logger.trace("sending invoice callback for payment", checking_id)
await payment.set_pending(False)
for send_chan in invoice_listeners:
await send_chan.put(payment)