diff --git a/config.ini.sample b/config.ini.sample index cc9c48c..c979083 100644 --- a/config.ini.sample +++ b/config.ini.sample @@ -1,5 +1,6 @@ [DEFAULT] +logs = /var/log/kabot/kabot.log audio_path = /tmp/ voice_channel = channel_name text_channel = channel_name diff --git a/kabot/kabot/kabot.py b/kabot/kabot/kabot.py index cdfdbc3..1fd108d 100644 --- a/kabot/kabot/kabot.py +++ b/kabot/kabot/kabot.py @@ -35,12 +35,6 @@ logger.setLevel(logging.INFO) ## format du log formatter = logging.Formatter('%(asctime)s :: %(levelname)s :: %(message)s') -## definition du fichier de log (chemin, level, etc ...) -file_handler = RotatingFileHandler('/var/log/kabot/kabot.log', 'a', 1000000, 1) -file_handler.setLevel(logging.INFO) -file_handler.setFormatter(formatter) -logger.addHandler(file_handler) - ## definition de l'affichage des logs dans la console stream_handler = logging.StreamHandler() stream_handler.setLevel(logging.INFO) @@ -563,6 +557,12 @@ def main(): ) args = parser.parse_args() config = configparser.ConfigParser() + log_file = config['DEFAULT']['logs'] + ## definition du fichier de log (chemin, level, etc ...) + file_handler = RotatingFileHandler(log_file, 'a', 1000000, 1) + file_handler.setLevel(logging.INFO) + file_handler.setFormatter(formatter) + logger.addHandler(file_handler) if not os.path.exists(args.config): logger.critical('config file not found') exit(1)