Queer European MD passionate about IT
Bladeren bron

Logging configuration

Davte 6 jaren geleden
bovenliggende
commit
c0f57fbef4
2 gewijzigde bestanden met toevoegingen van 14 en 1 verwijderingen
  1. 1 1
      davtelepot/__init__.py
  2. 13 0
      davtelepot/custombot.py

+ 1 - 1
davtelepot/__init__.py

@@ -2,7 +2,7 @@ __author__ = "Davide Testa"
 __email__ = "davte@libero.it"
 __credits__ = "Marco Origlia"
 __license__ = "GNU General Public License v3.0"
-__version__ = "1.3.1"
+__version__ = "1.3.2"
 __maintainer__ = "Davide Testa"
 __contact__ = "t.me/davte"
 

+ 13 - 0
davtelepot/custombot.py

@@ -1880,6 +1880,19 @@ class Bot(telepot.aio.Bot, Gettable):
 
 
 if __name__ == '__main__':
+    log_formatter = logging.Formatter(
+        "%(asctime)s [%(module)-15s %(levelname)-8s]     %(message)s",
+        style='%'
+    )
+    # Get root logger and set level to DEBUG
+    root_logger = logging.getLogger()
+    root_logger.setLevel(logging.DEBUG)
+    # ConsoleHandler (log to terminal)
+    ConsoleHandler = logging.StreamHandler()
+    ConsoleHandler.setFormatter(log_formatter)
+    ConsoleHandler.setLevel(logging.DEBUG)
+    # Add ConsoleHandler to root_logger
+    root_logger.addHandler(ConsoleHandler)
     # from davtelepot.custombot import Bot
     # davtebot = Bot.get('335545766:AAEVvbdqy7OCG7ufxBwKVdBscdfddFF2lmk')
     # davtetest = Bot.get('279769259:AAEri-FF8AZeLz0LAi4BpPVjkQcKeOOTimo')