Remove PosixPath() in logs and add proper exception logging
This commit is contained in:
parent
1e6655a715
commit
2bf809c454
@ -321,8 +321,8 @@ async def start_session() -> None:
|
|||||||
except ClientError as c:
|
except ClientError as c:
|
||||||
write(err("Something went wrong"))
|
write(err("Something went wrong"))
|
||||||
logger.error(f"Unexpected client error: {c}")
|
logger.error(f"Unexpected client error: {c}")
|
||||||
except Exception as e:
|
except:
|
||||||
logger.error(f"Serious client error: {e}")
|
logger.exception("Serious client error")
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
with contextlib.suppress(KeyError):
|
with contextlib.suppress(KeyError):
|
||||||
@ -371,7 +371,7 @@ async def create_pop_server(
|
|||||||
timeout_seconds: int = 60,
|
timeout_seconds: int = 60,
|
||||||
) -> asyncio.Server:
|
) -> asyncio.Server:
|
||||||
logging.info(
|
logging.info(
|
||||||
f"Starting POP3 server {host=}, {port=}, {mails_path=}, {len(users)=}, {ssl_context != None=}, {timeout_seconds=}"
|
f"Starting POP3 server {host=}, {port=}, {mails_path=!s}, {len(users)=}, {ssl_context != None=}, {timeout_seconds=}"
|
||||||
)
|
)
|
||||||
return await asyncio.start_server(
|
return await asyncio.start_server(
|
||||||
make_pop_server_callback(mails_path, users, timeout_seconds),
|
make_pop_server_callback(mails_path, users, timeout_seconds),
|
||||||
|
@ -150,7 +150,7 @@ def main() -> None:
|
|||||||
else:
|
else:
|
||||||
cfg = config.Config(args.config.read_text())
|
cfg = config.Config(args.config.read_text())
|
||||||
setup_logging(config.LogCfg(cfg.logging))
|
setup_logging(config.LogCfg(cfg.logging))
|
||||||
logging.info(f"Starting mail4one {args.config=}")
|
logging.info(f"Starting mail4one {args.config=!s}")
|
||||||
asyncio.run(a_main(cfg))
|
asyncio.run(a_main(cfg))
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,8 +75,8 @@ def protocol_factory_starttls(mails_path: Path,
|
|||||||
tls_context=context,
|
tls_context=context,
|
||||||
enable_SMTPUTF8=True,
|
enable_SMTPUTF8=True,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except:
|
||||||
logger.error("Something went wrong", e)
|
logger.exception("Something went wrong")
|
||||||
raise
|
raise
|
||||||
return smtp
|
return smtp
|
||||||
|
|
||||||
@ -87,8 +87,8 @@ def protocol_factory(mails_path: Path, mbox_finder: Callable[[str],
|
|||||||
try:
|
try:
|
||||||
handler = MyHandler(mails_path, mbox_finder)
|
handler = MyHandler(mails_path, mbox_finder)
|
||||||
smtp = SMTP(handler=handler, enable_SMTPUTF8=True)
|
smtp = SMTP(handler=handler, enable_SMTPUTF8=True)
|
||||||
except Exception as e:
|
except:
|
||||||
logger.error("Something went wrong", e)
|
logger.exception("Something went wrong")
|
||||||
raise
|
raise
|
||||||
return smtp
|
return smtp
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ async def create_smtp_server_starttls(
|
|||||||
ssl_context: ssl.SSLContext,
|
ssl_context: ssl.SSLContext,
|
||||||
) -> asyncio.Server:
|
) -> asyncio.Server:
|
||||||
logging.info(
|
logging.info(
|
||||||
f"Starting SMTP STARTTLS server {host=}, {port=}, {mails_path=}, {ssl_context != None=}"
|
f"Starting SMTP STARTTLS server {host=}, {port=}, {mails_path=!s}, {ssl_context != None=}"
|
||||||
)
|
)
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
return await loop.create_server(
|
return await loop.create_server(
|
||||||
@ -121,7 +121,7 @@ async def create_smtp_server(
|
|||||||
ssl_context: ssl.SSLContext | None = None,
|
ssl_context: ssl.SSLContext | None = None,
|
||||||
) -> asyncio.Server:
|
) -> asyncio.Server:
|
||||||
logging.info(
|
logging.info(
|
||||||
f"Starting SMTP server {host=}, {port=}, {mails_path=}, {ssl_context != None=}"
|
f"Starting SMTP server {host=}, {port=}, {mails_path=!s}, {ssl_context != None=}"
|
||||||
)
|
)
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
return await loop.create_server(
|
return await loop.create_server(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user