Don't create log file if not specified

This commit is contained in:
Pawel Kierski
2019-03-05 11:28:23 +01:00
committed by Paweł Kierski
parent 788d2550e6
commit 67e7a4c0b2

View File

@@ -318,19 +318,22 @@ class Plugin():
def _prepare_logging(logger_file):
root = logging.getLogger()
root.setLevel(logging.DEBUG)
handler = logging.handlers.RotatingFileHandler(
logger_file,
mode="a",
maxBytes=10000000,
backupCount=10,
encoding="utf-8"
)
if logger_file:
handler = logging.handlers.RotatingFileHandler(
logger_file,
mode="a",
maxBytes=10000000,
backupCount=10,
encoding="utf-8"
)
else:
handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
root.addHandler(handler)
def create_and_run_plugin(plugin_class, argv):
logger_file = argv[3] if len(argv) >= 4 else "output.log"
logger_file = argv[3] if len(argv) >= 4 else None
_prepare_logging(logger_file)
if len(argv) < 3: