From 1b5526204313cc43c5aa7b247c306570ad3fbbc0 Mon Sep 17 00:00:00 2001 From: HannesBachter Date: Tue, 26 Mar 2024 11:50:14 +0100 Subject: [PATCH] add option to define logging level --- README.md | 6 +++--- robmuxinator/robmuxinator.py | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 65adfa8..b4a6ce2 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ It is also helpful for local development to start multiple commands easily with ## Installation -Install the robmuxinator with one simple command +Install the robmuxinator with one simple command (execute in the `robmuxinator` package) ``` sudo pip install . ``` @@ -60,7 +60,7 @@ sessions: host: localhost prio: 1 command: echo 'starting bringup...' - + ``` To start the `tmux` sessions use `robmuxinator -c ~/path-to-file start`. Now, you are able to see your sessions with `tmux ls` @@ -94,7 +94,7 @@ sessions: host: h2 prio: 1 command: echo 'starting bringup...' - + ``` ## Usage ### Command Choices diff --git a/robmuxinator/robmuxinator.py b/robmuxinator/robmuxinator.py index 3f1ecf0..65a38bd 100755 --- a/robmuxinator/robmuxinator.py +++ b/robmuxinator/robmuxinator.py @@ -84,7 +84,6 @@ def format(self, record): logging.addLevelName(logging.CRITICAL, "C") logger = logging.getLogger(__name__) -logger.setLevel(logging.INFO) custom_format = CustomFormatter() @@ -750,6 +749,14 @@ def main(): action="store_true", help="close sessions even if they are locked", ) + parser.add_argument( + "-l", + "--logging_level", + required=False, + choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], + default="INFO", + help="logging level", + ) argcomplete.autocomplete(parser) args = parser.parse_args() @@ -757,6 +764,9 @@ def main(): yaml_file = args.config command = args.command + # set logging level + logger.setLevel(level=args.logging_level) + # load yaml file with open(yaml_file, "r") as fs: yaml_content = yaml.safe_load(fs)