Ben Kurtovic 13 anni fa
parent
commit
17128ae9ae
3 ha cambiato i file con 8 aggiunte e 6 eliminazioni
  1. +1
    -1
      bot/classes/base_command.py
  2. +1
    -1
      bot/classes/base_task.py
  3. +6
    -4
      bot/config.py

+ 1
- 1
bot/classes/base_command.py Vedi File

@@ -24,7 +24,7 @@ class BaseCommand(object):
from within a method.
"""
self.connection = connection
self.logger = logging.getLogger(".".join(("commands", name)))
self.logger = logging.getLogger(".".join(("commands", self.name)))
self.logger.setLevel(logging.DEBUG)

def check(self, data):


+ 1
- 1
bot/classes/base_task.py Vedi File

@@ -20,7 +20,7 @@ class BaseTask(object):

def _setup_logger(self):
"""Set up a basic module-level logger."""
self.logger = logging.getLogger(".".join(("tasks", name)))
self.logger = logging.getLogger(".".join(("tasks", self.name)))
self.logger.setLevel(logging.DEBUG)

def run(self, **kwargs):


+ 6
- 4
bot/config.py Vedi File

@@ -26,6 +26,7 @@ Additionally, there are functions used in config loading:

import json
import logging
import logging.handlers
from os import path

import blowfish
@@ -57,22 +58,23 @@ def _setup_logging():
logger.setLevel(logging.DEBUG)

if metadata.get("enableLogging"):
import logging.handlers
hand = logging.handlers.TimedRotatingFileHandler
fmt = "[%(asctime)s %(levelname)-8s] %(name)s: %(message)s"
formatter = logging.Formatter(fmt=fmt, datefmt="%Y-%m-%d %H:%M:%S")

logfile = lambda f: path.join(log_dir, f)

main_handler = hand(logfile("bot.log"), "midnight", 1. 7)
error_handler = hand(logfile("error.log"), "W", 6, 4)
main_handler = hand(logfile("bot.log"), "midnight", 1, 7)
error_handler = hand(logfile("error.log"), "W6", 1, 4)
debug_handler = hand(logfile("debug.log"), "H", 1, 6)
stream_handler = logging.StreamHandler()

main_handler.setLevel(logging.INFO)
error_handler.setLevel(logging.ERROR)
debug_handler.setLevel(logging.DEBUG)
stream_handler.setLevel(logging.DEBUG)

handlers = (main_handler, error_handler, debug_handler)
handlers = (main_handler, error_handler, debug_handler, stream_handler)
for h in handlers:
h.setFormatter(formatter)
logger.addHandler(h)


Caricamento…
Annulla
Salva