diff options
author | Maxim Devaev <[email protected]> | 2022-06-19 22:30:17 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2022-06-19 22:30:17 +0300 |
commit | a70800323e4932d1885a210315af8c986bd2f7f9 (patch) | |
tree | d6501a2220775653266c917bf6ecde5c56e57854 | |
parent | 804bb68ae3fe21a79cfde0de91ce6e11642a5bb8 (diff) |
cli logging mode
-rw-r--r-- | kvmd/apps/__init__.py | 6 | ||||
-rw-r--r-- | kvmd/apps/htpasswd/__init__.py | 1 | ||||
-rw-r--r-- | kvmd/apps/otgconf/__init__.py | 1 | ||||
-rw-r--r-- | kvmd/apps/otgmsd/__init__.py | 1 | ||||
-rw-r--r-- | kvmd/apps/pstrun/__init__.py | 1 |
5 files changed, 10 insertions, 0 deletions
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py index 314c6b1b..cef0a6a4 100644 --- a/kvmd/apps/__init__.py +++ b/kvmd/apps/__init__.py @@ -113,6 +113,7 @@ def init( description: Optional[str]=None, add_help: bool=True, check_run: bool=False, + cli_logging: bool=False, argv: Optional[List[str]]=None, **load: bool, ) -> Tuple[argparse.ArgumentParser, List[str], Section]: @@ -152,6 +153,11 @@ def init( logging.captureWarnings(True) logging.config.dictConfig(config.logging) + if cli_logging: + logging.getLogger().handlers[0].setFormatter(logging.Formatter( + "-- {levelname:>7} -- {message}", + style="{", + )) if check_run and not options.run: raise SystemExit( diff --git a/kvmd/apps/htpasswd/__init__.py b/kvmd/apps/htpasswd/__init__.py index fac9a5ec..c46564dd 100644 --- a/kvmd/apps/htpasswd/__init__.py +++ b/kvmd/apps/htpasswd/__init__.py @@ -128,6 +128,7 @@ def _cmd_delete(config: Section, options: argparse.Namespace) -> None: def main(argv: Optional[List[str]]=None) -> None: (parent_parser, argv, config) = init( add_help=False, + cli_logging=True, argv=argv, load_auth=True, ) diff --git a/kvmd/apps/otgconf/__init__.py b/kvmd/apps/otgconf/__init__.py index 61701ccf..389e1721 100644 --- a/kvmd/apps/otgconf/__init__.py +++ b/kvmd/apps/otgconf/__init__.py @@ -114,6 +114,7 @@ class _GadgetControl: def main(argv: Optional[List[str]]=None) -> None: (parent_parser, argv, config) = init( add_help=False, + cli_logging=True, argv=argv, ) parser = argparse.ArgumentParser( diff --git a/kvmd/apps/otgmsd/__init__.py b/kvmd/apps/otgmsd/__init__.py index f57b3107..0d32331b 100644 --- a/kvmd/apps/otgmsd/__init__.py +++ b/kvmd/apps/otgmsd/__init__.py @@ -60,6 +60,7 @@ def _set_param(gadget: str, instance: int, param: str, value: str) -> None: def main(argv: Optional[List[str]]=None) -> None: (parent_parser, argv, config) = init( add_help=False, + cli_logging=True, argv=argv, load_msd=True, ) diff --git a/kvmd/apps/pstrun/__init__.py b/kvmd/apps/pstrun/__init__.py index 00d98557..c00dea4b 100644 --- a/kvmd/apps/pstrun/__init__.py +++ b/kvmd/apps/pstrun/__init__.py @@ -112,6 +112,7 @@ async def _run_cmd(cmd: List[str], unix_path: str) -> None: def main(argv: Optional[List[str]]=None) -> None: (parent_parser, argv, config) = init( add_help=False, + cli_logging=True, argv=argv, ) parser = argparse.ArgumentParser( |