mirror of
https://github.com/onyx-and-iris/obsws-cli.git
synced 2026-02-16 09:57:49 +00:00
use getLevelNamesMapping() to get loglevel names
This commit is contained in:
parent
fb19a67e64
commit
7f3d47e7b0
@ -30,13 +30,13 @@ def version_callback(value: bool):
|
|||||||
|
|
||||||
def setup_logging(loglevel: str):
|
def setup_logging(loglevel: str):
|
||||||
"""Set up logging for the application."""
|
"""Set up logging for the application."""
|
||||||
loglevel = loglevel.upper()
|
numeric_loglevel = logging.getLevelNamesMapping().get(loglevel.upper())
|
||||||
if loglevel not in ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']:
|
if numeric_loglevel is None:
|
||||||
raise typer.BadParameter(
|
raise typer.BadParameter(
|
||||||
f'Invalid log level: {loglevel}. Choose from DEBUG, INFO, WARNING, ERROR, CRITICAL.'
|
f'Invalid log level: {loglevel}. Valid options are: {", ".join(logging.getLevelNamesMapping().keys())}'
|
||||||
)
|
)
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=loglevel,
|
level=numeric_loglevel,
|
||||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user