mirror of
https://github.com/onyx-and-iris/obsws-cli.git
synced 2026-02-16 09:57:49 +00:00
remove --debug flag, replace it with --loglevel
This commit is contained in:
parent
45479563a0
commit
13a2443d48
@ -28,11 +28,15 @@ def version_callback(value: bool):
|
||||
raise typer.Exit()
|
||||
|
||||
|
||||
def setup_logging(debug: bool):
|
||||
def setup_logging(loglevel: str):
|
||||
"""Set up logging for the application."""
|
||||
log_level = logging.DEBUG if debug else logging.CRITICAL
|
||||
loglevel = loglevel.upper()
|
||||
if loglevel not in ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']:
|
||||
raise typer.BadParameter(
|
||||
f'Invalid log level: {loglevel}. Choose from DEBUG, INFO, WARNING, ERROR, CRITICAL.'
|
||||
)
|
||||
logging.basicConfig(
|
||||
level=log_level,
|
||||
level=loglevel,
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||||
)
|
||||
|
||||
@ -121,19 +125,18 @@ def main(
|
||||
callback=version_callback,
|
||||
),
|
||||
] = False,
|
||||
debug: Annotated[
|
||||
bool,
|
||||
loglevel: Annotated[
|
||||
str,
|
||||
typer.Option(
|
||||
'--debug',
|
||||
'-d',
|
||||
envvar='OBSWS_CLI_DEBUG',
|
||||
'--loglevel',
|
||||
'-l',
|
||||
envvar='OBSWS_CLI_LOGLEVEL',
|
||||
is_eager=True,
|
||||
help='Enable debug logging',
|
||||
help='Set the logging level',
|
||||
show_default=False,
|
||||
callback=setup_logging,
|
||||
hidden=True,
|
||||
),
|
||||
] = envconfig.get('debug'),
|
||||
] = envconfig.get('loglevel'),
|
||||
):
|
||||
"""obsws_cli is a command line interface for the OBS WebSocket API."""
|
||||
ctx.ensure_object(dict)
|
||||
|
||||
@ -124,7 +124,7 @@ _envconfig = EnvConfig(
|
||||
OBSWS_CLI_PORT=4455,
|
||||
OBSWS_CLI_PASSWORD='',
|
||||
OBSWS_CLI_TIMEOUT=5,
|
||||
OBSWS_CLI_DEBUG=False,
|
||||
OBSWS_CLI_LOGLEVEL='WARNING',
|
||||
OBSWS_CLI_STYLE='disabled',
|
||||
OBSWS_CLI_STYLE_NO_BORDER=False,
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user