From fe6e3ba1a61ec3feea3431fbed4fc1accb955d6d Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 19 Sep 2018 00:13:41 +0200 Subject: [PATCH] Log formatting --- bots.py | 2 +- db.py | 7 ++++++- discordbot.py | 1 + redditbot.py | 1 + statsupdate.py | 1 + telegrambot.py | 1 + 6 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bots.py b/bots.py index 5febe5a7..e878ebab 100644 --- a/bots.py +++ b/bots.py @@ -8,10 +8,10 @@ import logging import coloredlogs import os -os.environ["COLOREDLOGS_LOG_FORMAT"] = "%(asctime)s %(levelname)s %(name)s %(message)s" logging.getLogger().disabled = True logger = logging.getLogger(__name__) +os.environ["COLOREDLOGS_LOG_FORMAT"] = "%(asctime)s %(levelname)s %(name)s %(message)s" coloredlogs.install(level="DEBUG", logger=logger) discord_telegram_pipe = multiprocessing.Pipe() diff --git a/db.py b/db.py index 7939eea8..14349eb7 100644 --- a/db.py +++ b/db.py @@ -1,6 +1,7 @@ import datetime import logging - +import os +import coloredlogs from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker, relationship, joinedload from sqlalchemy.ext.hybrid import hybrid_property @@ -22,6 +23,10 @@ engine = create_engine(config["Database"]["database_uri"]) Base = declarative_base(bind=engine) Session = sessionmaker(bind=engine) +logging.getLogger().disabled = True +logger = logging.getLogger(__name__) +os.environ["COLOREDLOGS_LOG_FORMAT"] = "%(asctime)s %(levelname)s %(name)s %(message)s" +coloredlogs.install(level="DEBUG", logger=logger) class Royal(Base): __tablename__ = "royals" diff --git a/discordbot.py b/discordbot.py index 996d9c09..b013aff1 100644 --- a/discordbot.py +++ b/discordbot.py @@ -22,6 +22,7 @@ import coloredlogs logging.getLogger().disabled = True logger = logging.getLogger(__name__) +os.environ["COLOREDLOGS_LOG_FORMAT"] = "%(asctime)s %(levelname)s %(name)s %(message)s" coloredlogs.install(level="DEBUG", logger=logger) # Queue emojis diff --git a/redditbot.py b/redditbot.py index a23d4cc3..8f9f7893 100644 --- a/redditbot.py +++ b/redditbot.py @@ -15,6 +15,7 @@ config.read("config.ini") logging.getLogger().disabled = True logger = logging.getLogger(__name__) +os.environ["COLOREDLOGS_LOG_FORMAT"] = "%(asctime)s %(levelname)s %(name)s %(message)s" coloredlogs.install(level="DEBUG", logger=logger) sentry = raven.Client(config["Sentry"]["token"], diff --git a/statsupdate.py b/statsupdate.py index 62a20068..be2ff4bc 100644 --- a/statsupdate.py +++ b/statsupdate.py @@ -11,6 +11,7 @@ import coloredlogs logging.getLogger().disabled = True logger = logging.getLogger(__name__) +os.environ["COLOREDLOGS_LOG_FORMAT"] = "%(asctime)s %(levelname)s %(name)s %(message)s" coloredlogs.install(level="DEBUG", logger=logger) # Init the config reader diff --git a/telegrambot.py b/telegrambot.py index 52bdd329..604dee05 100644 --- a/telegrambot.py +++ b/telegrambot.py @@ -26,6 +26,7 @@ except Exception: logging.getLogger().disabled = True logger = logging.getLogger(__name__) +os.environ["COLOREDLOGS_LOG_FORMAT"] = "%(asctime)s %(levelname)s %(name)s %(message)s" coloredlogs.install(level="DEBUG", logger=logger) # Init the config reader