added date/time to message log
Signed-off-by: klux2 <k.lux.gm@gmail.com>
This commit is contained in:
parent
cc6ebfdc2a
commit
9f92a7164e
1 changed files with 6 additions and 2 deletions
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue