Skip to main content

Logging to stderr and file for click applications.

Project description

click_loguru initializes loguru for logging to stderr and (optionally) a file for use with a click CLI.

If your click application uses subcommands (via @click.group()), log files will include the subcommand in the name. Log files are numbered, with a retention policy specified. Log files can be enabled or disabled per-subcommand and written to a subdirectory your application specifies.

Global options control verbose, quiet, and logfile creation. The values of these global options are accessible from your application.

Instantiation is from a single class, ClickLoguru, with the arguments of the name and version of your application. Optional keyworded arguments are the integer retention to set the number of log files retained per-application to values other than the default (4), log_dir_parent to set the location of the log file directory other than its default value of ./logs, file_log_level to set the level of logging to the file other than the default of DEBUG, and stderr_log_level which by default is set to INFO.

The logging_options method returns a decorator to be used for the CLI method which defines the global options that allows control of quiet, verbose, and logfile booleans.

The stash_subcommand method returns a decorator to be used for the CLI method for applications which define subcommands.

The init_logger method returns a decorator which must be used for each subcommand. It allows override of the default log_dir_parent established at instantiation, as well as turning off file logging for that command by setting logfile to False.

The log_elapsed_time method returns a decorator which causes the elapsed time for the subcommand to be emitted at the DEBUG level.

The get_global_options method returns the context object associated with the global options. The context object is printable. The attributes of the context object are the booleans verbose, quiet, and logfile, the string subcommand showing the subcommand that was invoked, and logfile_handler_id if your code wishes to manipulate the handler directly.

See the file tests/__init__.py for usage examples.

Prerequisites

Python 3.6 or greater is required. This package is tested under Linux and MacOS using Python 3.7.

Project Status

Latest Release

Python package

GitHub

GitHub repository

License

License terms

Travis Build

Travis CI

Coverage

Codecov.io test coverage

Code Grade

Codacy.io grade

Dependencies

dependabot dependencies

Pre-commit

pre-commit

Issues

Issues reported

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

click_loguru-0.3.6.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

click_loguru-0.3.6-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file click_loguru-0.3.6.tar.gz.

File metadata

  • Download URL: click_loguru-0.3.6.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.9 CPython/3.8.3 Linux/5.7.4-gentoo-x86_64

File hashes

Hashes for click_loguru-0.3.6.tar.gz
Algorithm Hash digest
SHA256 36f4b58ca24146ff6465bcbec613feec1165e3ace8da353b575a8492417e7889
MD5 71e3fca929253e3e4c324a2123117c23
BLAKE2b-256 3bf1e18fd97d81bf9e78afd202f060fccf18c474fce3ab0c5cd39cc6d34552b7

See more details on using hashes here.

File details

Details for the file click_loguru-0.3.6-py3-none-any.whl.

File metadata

  • Download URL: click_loguru-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.9 CPython/3.8.3 Linux/5.7.4-gentoo-x86_64

File hashes

Hashes for click_loguru-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 94f67c9811235f2055fbc52805fd75adc2343131dc34937c297acee3710f0c2a
MD5 5531064e61b62a1419e2a7ca46dc7368
BLAKE2b-256 588f8082c8830d06b158c32fd2b535c0107763297b72ff6e470cbb70e8583cd1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page