diff --git a/HSMensaW_botA.py b/HSMensaW_botA.py index f50bc8d..f900fb6 100644 --- a/HSMensaW_botA.py +++ b/HSMensaW_botA.py @@ -150,7 +150,7 @@ async def send_status(text: str, ignore_flag: bool = False) -> None: :return: """ global config_ids - message_log.write(text + "\n") + message_log.write("[%s] %s\n" % (get_now(), text)) if ignore_flag or logging_enabled: for chat_id in config_ids: await send_message(bot_obj=bot, chat_id=chat_id, msg=text) @@ -196,7 +196,7 @@ async def get_essen(only_today: bool) -> None: return except Exception as expt: await send_status("Es ist ein Fehler aufgetreten:\n[%s] %s" % (sys.exc_info()[0], str(expt)), ignore_flag=True) - print("[%s] Fehler:\n%s" % (datetime.datetime.now().strftime("%Y-%m-%d %H:%M"), traceback.format_exc()), + print("[%s] Fehler:\n%s" % (get_now(), traceback.format_exc()), file=sys.stderr) var = True return @@ -295,6 +295,10 @@ async def essen_loop() -> None: await asyncio.sleep(30) +def get_now() -> str: + return datetime.datetime.now().strftime("%Y-%m-%d %H:%M") + + sys.stdout = open("out.log", "a") sys.stderr = open("err.log", "a") message_log = open("msg.log", "a")