Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core.server_scripts.Common): Set log level and format. #797

Merged
merged 3 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/pysmurf/client/base/smurf_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def validate_config(loaded_config):

# data_out_mux
Optional("data_out_mux",
default=default_data_out_mux_dict[band]) : \
default=default_data_out_mux_dict[band]) :
And([Use(int)], list, lambda l: len(l) == 2 and
l[0] != l[1] and all(0 <= ll <= 9 for ll in l)),

Expand Down
15 changes: 15 additions & 0 deletions python/pysmurf/core/server_scripts/Common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import subprocess
import sys
import zipfile
import logging

import pyrogue

Expand All @@ -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
Expand Down Expand Up @@ -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
Loading