mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 17:20:30 +08:00
cli logging mode
This commit is contained in:
parent
804bb68ae3
commit
a70800323e
@ -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(
|
||||
|
||||
@ -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,
|
||||
)
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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,
|
||||
)
|
||||
|
||||
@ -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(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user