Skip to main content

A duck‑themed logging system for Python, with colorful output and file logging.

Project description

ducktrace‑python

A duck‑themed logging system for Python, with colourful console output and automatic file logging.

🦆 Works seamlessly with the ducktrace family:

Features

  • 📄 Logs are written to ~/.config/duckTrace/ (configurable via DT_LOG_PATH)

  • 🎨 Colourful, duck‑themed console output

  • 📁 Respects DT_LOG_LEVEL and DT_LOG_FILE environment variables

  • ⏱️ Includes a dt_timer decorator and PerformanceTimer context manager for performance measurement

  • 🛠️ Simple dt_debug, dt_info, … functions for quick logging


Installation

pip install ducktrace

Or directly from GitHub:

pip install git+https://github.com/QuackHack-McBlindy/ducktrace-python.git

NixOS (using flakes)

Add the flake input to your flake.nix:

{
  inputs.ducktrace-python.url = "github:QuackHack-McBlindy/ducktrace-python";

  outputs = { self, nixpkgs, ducktrace-python, ... }: {
    nixosConfigurations.myMachine = nixpkgs.lib.nixosSystem {
      modules = [
        {
          environment.systemPackages = [
            ducktrace-python.packages.${system}.default
          ];
        }
      ];
    };
  };
}

Build from source

$ git clone https://github.com/QuackHack-McBlindy/ducktrace-python.git
$ cd ducktrace-python
$ pip install .

Or with Nix (inside the repo):

nix build
# result/ will contain the package

Usage

import ducktrace

# Initialise logging (reads DT_LOG_LEVEL, DT_LOG_PATH, DT_LOG_FILE)
ducktrace.dt_setup()

ducktrace.dt_info("Application started")
ducktrace.dt_debug("This is a debug message")
ducktrace.dt_error("Something went wrong")

# Timing decorator
@ducktrace.dt_timer()
def slow_function():
    time.sleep(1)

slow_function()

# Context manager timer
with ducktrace.PerformanceTimer("database query") as timer:
    # … some work …
    timer.lap("after connect")
    # … more work …

Environment Variables

$DT_LOG_LEVEL – DEBUG, INFO, WARNING, ERROR, CRITICAL (default: INFO)

$DT_LOG_PATH – directory for log files (default: ~/.config/duckTrace/)

$DT_LOG_FILE – filename inside that directory (default: PyDuckTrace.log)



License

MIT

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

ducktrace-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

ducktrace-0.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file ducktrace-0.1.0.tar.gz.

File metadata

  • Download URL: ducktrace-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.12

File hashes

Hashes for ducktrace-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0e42e3694ea8063d82d201e8f19a3b5be56c2213319aaba7e90d4a154c0fd57c
MD5 6e253373a4ad2e0ca504370f2b9af44a
BLAKE2b-256 27485a4355364eeb74714b0a48fca1e96cda52fe6957d710571d8edf2d517bbc

See more details on using hashes here.

File details

Details for the file ducktrace-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ducktrace-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.12

File hashes

Hashes for ducktrace-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d29650bb6b5519648cf0b3cba0136ec40e12755a7139c3173fc66a73b29b9707
MD5 2403f93a1bd40b927da66839324cb41f
BLAKE2b-256 0b216dd7d2e55cdd44e5ba4e129ba0e775da4b360b5bcd629913c140b508fa61

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