Skip to content

Instantly share code, notes, and snippets.

@thoroc
Created April 14, 2023 07:38
Show Gist options
  • Save thoroc/f4978059839abb64eeadbcd772705fd2 to your computer and use it in GitHub Desktop.
Save thoroc/f4978059839abb64eeadbcd772705fd2 to your computer and use it in GitHub Desktop.
How to set the cli app to show debug logs with loguru
import click
from loguru import logger
@click.command()
@click.option(
"-d",
"--debug",
is_flag=True,
help="Enable debug mode. Prints debug messages to the console.",
)
def main(debug: bool):
if not debug:
# default loguru level is DEBUG
logger.remove()
logger.add(sys.stderr, level="INFO")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment