'bot.log' -> 'trace.log' and add a 'warn.log' log file that only catches
warn-and-worse
This commit is contained in:
parent
5b70f37796
commit
8cd069d37d
2 changed files with 13 additions and 8 deletions
|
@ -43,11 +43,16 @@ class Log(object):
|
|||
stdout_handler.setFormatter(formatter)
|
||||
self.logger.addHandler(stdout_handler)
|
||||
|
||||
file_handler = logging.handlers.TimedRotatingFileHandler(
|
||||
location, when="midnight", backupCount=5)
|
||||
file_handler.setLevel(LEVELS["trace"])
|
||||
file_handler.setFormatter(formatter)
|
||||
self.logger.addHandler(file_handler)
|
||||
trace_handler = logging.handlers.TimedRotatingFileHandler(
|
||||
os.path.join(location, "trace.log"), when="midnight", backupCount=5)
|
||||
trace_handler.setLevel(LEVELS["trace"])
|
||||
trace_handler.setFormatter(formatter)
|
||||
self.logger.addHandler(trace_handler)
|
||||
|
||||
warn_handler = logging.FileHandler(os.path.join(location, "warn.log"))
|
||||
warn_handler.setLevel(LEVELS["warn"])
|
||||
warn_handler.setFormatter(formatter)
|
||||
self.logger.addHandler(warn_handler)
|
||||
|
||||
def trace(self, message: str, params: typing.List, **kwargs):
|
||||
self._log(message, params, LEVELS["trace"], kwargs)
|
||||
|
|
6
start.py
6
start.py
|
@ -17,9 +17,9 @@ arg_parser.add_argument("--database", "-d",
|
|||
help="Location of the sqlite3 database file",
|
||||
default=os.path.join(directory, "databases", "bot.db"))
|
||||
|
||||
arg_parser.add_argument("--log", "-l",
|
||||
help="Location of the main log file",
|
||||
default=os.path.join(directory, "logs", "bot.log"))
|
||||
arg_parser.add_argument("--log-dir", "-l",
|
||||
help="Location of the log directory",
|
||||
default=os.path.join(directory, "logs"))
|
||||
|
||||
arg_parser.add_argument("--add-server", "-a",
|
||||
help="Add a new server", action="store_true")
|
||||
|
|
Loading…
Reference in a new issue