enabling logging to file
Signed-off-by: klux2 <k.lux.gm@gmail.com>
This commit is contained in:
parent
02e6a96e11
commit
3b424536ff
1 changed files with 6 additions and 0 deletions
|
@ -146,6 +146,7 @@ async def send_status(text: str, ignore_flag: bool = False) -> None:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
global config_ids
|
global config_ids
|
||||||
|
message_log.write(text)
|
||||||
if ignore_flag or logging_enabled:
|
if ignore_flag or logging_enabled:
|
||||||
for chat_id in config_ids:
|
for chat_id in config_ids:
|
||||||
await send_message(bot_obj=bot, chat_id=chat_id, msg=text)
|
await send_message(bot_obj=bot, chat_id=chat_id, msg=text)
|
||||||
|
@ -256,7 +257,11 @@ def shutdown(signum, frame):
|
||||||
ml.close()
|
ml.close()
|
||||||
loop.stop()
|
loop.stop()
|
||||||
loop.close()
|
loop.close()
|
||||||
|
message_log.flush()
|
||||||
|
message_log.close()
|
||||||
|
sys.stdout.flush()
|
||||||
sys.stdout.close()
|
sys.stdout.close()
|
||||||
|
sys.stderr.flush()
|
||||||
sys.stderr.close()
|
sys.stderr.close()
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
@ -285,6 +290,7 @@ async def essen_loop() -> None:
|
||||||
|
|
||||||
sys.stdout = open("out.log", "a")
|
sys.stdout = open("out.log", "a")
|
||||||
sys.stderr = open("err.log", "a")
|
sys.stderr = open("err.log", "a")
|
||||||
|
message_log = open("msg.log", "a")
|
||||||
signal.signal(signal.SIGTERM, shutdown)
|
signal.signal(signal.SIGTERM, shutdown)
|
||||||
signal.signal(signal.SIGINT, shutdown)
|
signal.signal(signal.SIGINT, shutdown)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue