Skip to main content

Command line interface logging.

Project description

Command Line Interface

This python module is used to make your command line / terminal more fancy when printing / logging certain events.

Quick install

pip install cli-log

Examples

Basic usage

import cli

cli.info("Hello world!\nInfo event.")
cli.debug("Debug event.")
cli.warn(prefix="CORE", message="Warning event.")
cli.error("Error event.")
[16:30:52 / INFO] Hello world!
[16:30:52 / INFO] Info event.
[16:30:52 / DEBUG] Debug event.
[16:30:52 / WARN][CORE] Warning event.
[16:30:52 / ERROR] Error event.

Advanced usage

import cli

cli.info("Hello world!")
cli.add(severity="Testing", message="Hello", prefix="test", color=cli.MAGENTA)
cli.init(log_format="[{time} ! {severity}]{prefix} {message}", reset=True)
cli.error("Error between error raising.")
cli.init(reset=True) # Doesn't do anything because we didnt set format before
cli.debug("Should not get executed.")
cli.init(log_format="[{severity} ! {time}]{prefix} {message}")
cli.info(message="Hello", color=cli.BLACK)
[16:30:52 / INFO] Hello world!
[16:30:52 / TESTING][test] Hello
Traceback (most recent call last):
    File "usr/local/lib/python3.11/site-packages\cli-log\initialise.py", line 18, in init
        raise ValueError("Cannot use 'reset' parameter in combination with 'log_format'")
ValueError: Cannot use 'reset' parameter in combination with 'log_format'

[16:30:52 ! ERROR] Error between error raising.
[16:30:52 / DEBUG] Should not get executed.
[16:30:52 ! INFO] Hello

Here you can see that an error was raised due to the usage of the reset parameter in combination with the log_format parameter.

You can also see that the [16:30:52 / DEBUG] is not using [16:30:52 ! DEBUG] because the format was reset.

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

cli-log-1.0.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file cli-log-1.0.tar.gz.

File metadata

  • Download URL: cli-log-1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for cli-log-1.0.tar.gz
Algorithm Hash digest
SHA256 c7a0b961c5a9eb991fd20b1b27d5a1cdb0db82592c6aa88ba91b2990b8f0b706
MD5 db2b27c343d655e0b34fa938028ab5fa
BLAKE2b-256 9c6be7ed08ea7b70ce63f2dd741f559caee38bdb2d4f9822d3d46a51b3dd13ae

See more details on using hashes here.

Supported by

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