From b383c004e2f23929b89ccded68a95f4221b39b35 Mon Sep 17 00:00:00 2001 From: Tristan Pinsonneault-Marotte Date: Wed, 2 Oct 2024 13:31:23 -0700 Subject: [PATCH] SmurfCommandMixin._caput: Log not print kwargs message. --- python/pysmurf/client/command/smurf_command.py | 2 +- python/pysmurf/core/server_scripts/Common.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/python/pysmurf/client/command/smurf_command.py b/python/pysmurf/client/command/smurf_command.py index e8a297683..128857373 100644 --- a/python/pysmurf/client/command/smurf_command.py +++ b/python/pysmurf/client/command/smurf_command.py @@ -46,7 +46,7 @@ def _caput(self, pvname, val, atca=False, cast_type=True, **kwargs): for k,v in kwargs.items(): if v is not None: - print(f"Unexpected kwargs: {k} = {v}") + self.log(f"Unexpected kwargs: {k} = {v}", self.LOG_INFO) #err=True if err: diff --git a/python/pysmurf/core/server_scripts/Common.py b/python/pysmurf/core/server_scripts/Common.py index c60eec4c5..a214d3194 100755 --- a/python/pysmurf/core/server_scripts/Common.py +++ b/python/pysmurf/core/server_scripts/Common.py @@ -23,6 +23,7 @@ import subprocess import sys import zipfile +import logging import pyrogue @@ -48,6 +49,16 @@ def process_args(args): if it was not defined. """ + # Setup logging + logger = logging.getLogger() + logger.setLevel(args.log_level) + # set up a handler with timestamps + handler = logging.StreamHandler() + handler.setLevel(args.log_level) + formatter = logging.Formatter("[%(asctime)s] %(levelname)s:%(name)s: %(msg)s") + handler.setFormatter(formatter) + logger.addHandler(handler) + # Verify if the zip file was specified if args.zip_file: zip_file_name = args.zip_file @@ -204,5 +215,9 @@ def make_parser(parser=None): group.add_argument('--use-qt', action='store_true', dest='use_qt', default=False, help="Use the QT ." ) + group.add_argument('--log-level', type=str.upper, help="Set the logging level.", + choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], + default="WARNING" + ) return parser