Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-43040: Add command line options for setting log level and file #45

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 20 additions & 2 deletions python/felis/cli.py
Expand Up @@ -45,12 +45,30 @@

logger = logging.getLogger("felis")

loglevel_choices = ["CRITICAL", "FATAL", "ERROR", "WARNING", "INFO", "DEBUG"]


@click.group()
@click.version_option(__version__)
def cli() -> None:
@click.option(
"--log-level",
type=click.Choice(loglevel_choices),
envvar="FELIS_LOGLEVEL",
help="Felis log level",
default=logging.getLevelName(logging.INFO),
)
@click.option(
"--log-file",
type=click.Path(),
envvar="FELIS_LOGFILE",
help="Felis log file path",
)
def cli(log_level: str, log_file: str | None) -> None:
"""Felis Command Line Tools."""
logging.basicConfig(level=logging.INFO)
if log_file:
logging.basicConfig(filename=log_file, level=log_level)

Check warning on line 69 in python/felis/cli.py

View check run for this annotation

Codecov / codecov/patch

python/felis/cli.py#L69

Added line #L69 was not covered by tests
else:
logging.basicConfig(level=log_level)


@cli.command("create-all")
Expand Down