From 67e7a4c0b2ca38be9acd3c53cfedebfe603c7206 Mon Sep 17 00:00:00 2001 From: Pawel Kierski Date: Tue, 5 Mar 2019 11:28:23 +0100 Subject: [PATCH] Don't create log file if not specified --- galaxy/api/plugin.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/galaxy/api/plugin.py b/galaxy/api/plugin.py index 536f342..853d860 100644 --- a/galaxy/api/plugin.py +++ b/galaxy/api/plugin.py @@ -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: