1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 21:44:21 +00:00

Log formatting

This commit is contained in:
Steffo 2018-09-19 00:12:07 +02:00
parent bc89282834
commit db237412e2
2 changed files with 9 additions and 6 deletions

15
bots.py
View file

@ -2,10 +2,13 @@ import multiprocessing
import telegrambot import telegrambot
import discordbot import discordbot
import redditbot import redditbot
import statsupdater import statsupdate
import time import time
import logging import logging
import coloredlogs import coloredlogs
import os
os.environ["COLOREDLOGS_LOG_FORMAT"] = "%(asctime)s %(levelname)s %(name)s %(message)s"
logging.getLogger().disabled = True logging.getLogger().disabled = True
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -15,7 +18,7 @@ discord_telegram_pipe = multiprocessing.Pipe()
discord = multiprocessing.Process(target=discordbot.process, args=(discord_telegram_pipe[0],), daemon=True) discord = multiprocessing.Process(target=discordbot.process, args=(discord_telegram_pipe[0],), daemon=True)
telegram = multiprocessing.Process(target=telegrambot.process, args=(discord_telegram_pipe[1],), daemon=True) telegram = multiprocessing.Process(target=telegrambot.process, args=(discord_telegram_pipe[1],), daemon=True)
reddit = multiprocessing.Process(target=redditbot.process, daemon=True) reddit = multiprocessing.Process(target=redditbot.process, daemon=True)
stats = multiprocessing.Process(target=statsupdater.process, daemon=True) stats = multiprocessing.Process(target=statsupdate.process, daemon=True)
if __name__ == "__main__": if __name__ == "__main__":
logger.info("Starting Discord Bot process...") logger.info("Starting Discord Bot process...")
@ -24,7 +27,7 @@ if __name__ == "__main__":
telegram.start() telegram.start()
logger.info("Starting Reddit Bot process...") logger.info("Starting Reddit Bot process...")
reddit.start() reddit.start()
logger.info("Starting StatsUpdater process...") logger.info("Starting StatsUpdate process...")
stats.start() stats.start()
try: try:
while True: while True:
@ -49,8 +52,8 @@ if __name__ == "__main__":
if stats.exitcode is not None: if stats.exitcode is not None:
logger.warning(f"StatsUpdater exited with {stats.exitcode}") logger.warning(f"StatsUpdater exited with {stats.exitcode}")
del stats del stats
stats = multiprocessing.Process(target=statsupdater.process, daemon=True) stats = multiprocessing.Process(target=statsupdate.process, daemon=True)
logger.info("Restarting StatsUpdater process...") logger.info("Restarting StatsUpdate process...")
stats.start() stats.start()
time.sleep(10) time.sleep(10)
except KeyboardInterrupt: except KeyboardInterrupt:
@ -63,5 +66,5 @@ if __name__ == "__main__":
telegram.join() telegram.join()
logger.info("Waiting for Reddit Bot process to stop...") logger.info("Waiting for Reddit Bot process to stop...")
reddit.join() reddit.join()
logger.info("Waiting for StatsUpdater process to stop...") logger.info("Waiting for StatsUpdate process to stop...")
stats.join() stats.join()