Skip to main content

cli_logger

Easy logger for python command line programs using click.

What it does

Use this script in your programs to get pretty-printed messages printed to STDOUT. To see what it does, just execute the script in test_manuell (which does not contain a unit test, but a script to see what it does.

Here's a screenshot: screenshot of script test_logger.py

It comes with these features:

  • Setting a severity level, to hide non-relevant / verbouse output.
  • Printing text at level Debug, Information, Warning and Error.
  • Retrieve a return code in case a warning (1) or an error (2) has been raised.
  • Configurable progress bar.

How to use

Program initialisation

At program initialisation, use set_minimum_severity_level to decide from which level and above messages should be printed.

Level Rank MessageClass= Description
1 Lowest DEBUG Information helping to understand the program flow or to search for errors. Of course, developers might use debuggers, but consider a productive use where debugging is not possible.
2 INFORMATION Default level. Information to the user that does not require to intervent.
3 WARNING Hint that something hasn't been as expected. Results might be erreneous.
4 Highest ERROR Something went wrong and it wasn't possible to resolve the situation.

Program execution

Print to the screeneee

Use debug('my message'), information('my message'), warning and error to create output. log, information, set_minimum_severity_level, error, debug, warning, returnCode,

Print a progress bar

printProgressBar

Program termination

Retrieve a return code returnCode() which indicates if a warning or error has been issued. For sure, a discussion could be opened wether this is a good method or wether exceptions would suit better.

Rules to create a return code (last verified rule wins):

Event Return Code
Only messages of type DEBUG or INFORMATION have been issued. 0
At least one WARNING has been issued. 1
At least one ERROR has been issued. 2

Installation

The code has been published on PyPi. To install, just use the command pip --install cli-logger.

Metadata

Release files for cli-logger 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cli-logger 1.0.1
File Size Uploaded Provenance
cli_logger-1.0.1.tar.gz 3.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cli-logger 1.0.1
File Interpreter ABI Platform
cli_logger-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.8 kB

Release files / cli_logger-1.0.1.tar.gz

Download URL cli_logger-1.0.1.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
fb8f56e32ab499e9105c684d8965fb5dd6102f11deaf5bfb9a53b066797d8381
BLAKE2b-256 checksum
How to use checksums
641151563aefcea474ef7f99dcd6fbf4f61f5a7ee5c05a45f27f3691dca08804
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1

Release files / cli_logger-1.0.1-py3-none-any.whl

Download URL cli_logger-1.0.1-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c0e191b2c89d16c9f90d8760badee1fb3a7c600090a79c435c3ef55b4aeff4e
BLAKE2b-256 checksum
How to use checksums
28c639691e205bdbbf19a5854d22b0e51fd81c9a23c4611f145f4984aff596df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1

Security for cli-logger 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page