Skip to main content

A simple and colorful logging utility for console output with support for context manager.

Project description

Logita

Logita is a lightweight and customizable Python logging utility focused on improving developer experience in the console, with optional file logging support. It provides colored output, structured log levels, and a simple API designed primarily for CLI tools, scripts, and developer-facing applications.

Features

  • Timestamped log messages printed directly to the console.
  • Optional colored output using colorama.
  • Supported log levels:
    • debug
    • info
    • success (custom semantic level)
    • warning
    • error
    • critical
    • exception (with full traceback support)
  • Optional file logging using Python's built-in logging module.
  • Ability to print logs with or without a newline (useful for progress output).
  • Context manager support (with statement) for automatic exception capturing.
  • No dependency on global logging configuration.

Installation

pip install logita

Ensure colorama is installed:

pip install colorama

Basic Usage

from logita import Logita

with Logita(use_colors=True) as log:
    log.info("Informational message")
    log.success("Operation completed successfully")
    log.warning("Potential issue detected")
    log.error("An error occurred")
    log.debug("Processing...", line=False)
    log.debug(" done")
    log.critical("Critical failure")
    log.exception("Unhandled exception")

File Logging

Logita can optionally persist logs to a file while still printing to the console:

log = Logita(use_colors=True, log_file="app.log")
log.info("This message appears in the console and in the log file")

File logs use the following format:

[YYYY-MM-DD HH:MM:SS] [LEVEL] message

Constructor Parameters

  • use_colors (bool, default: True) Enables or disables colored console output.

  • log_file (str | None, default: None) Path to a file where logs will be written using the standard logging module.

Design Notes

  • Console output is handled explicitly via print for full control over formatting and colors.
  • File logging is isolated and handled by an internal logging.Logger instance.
  • Logita is best suited for scripts, CLI tools, and developer utilities.
  • It is not designed to replace full-featured logging frameworks in highly concurrent or distributed systems.

License

MIT License

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

logita-1.3.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

logita-1.3.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file logita-1.3.0.tar.gz.

File metadata

  • Download URL: logita-1.3.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for logita-1.3.0.tar.gz
Algorithm Hash digest
SHA256 2b6edb908dac24896394c3d20fdec93d9917c8fee7493d6318ac781f3debc7cd
MD5 195fb64ad60df0deac7253ff55030375
BLAKE2b-256 b42199453f7b6a7e279b2077e39c2d8777624c378129a9789fdd5e3b1a2d7293

See more details on using hashes here.

File details

Details for the file logita-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: logita-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for logita-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a0f6f5ce9735d4e29d8eae534f8db79f6d696160293e18c95010314a51b20670
MD5 941881afb942114d945d06a0a9ec60d9
BLAKE2b-256 b7f680f0f3e09913e33216061560d1c9587e7ae9af337fb44dbc03dcd00d4636

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