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:
- ducktrace‑tui (TUI for Viewing logs and service management)
- ducktrace‑logger (Rust apps)
- ducktrace‑sh (Bash scripts)
Features
-
📄 Logs are written to
~/.config/duckTrace/(configurable viaDT_LOG_PATH) -
🎨 Colourful, duck‑themed console output
-
📁 Respects
DT_LOG_LEVELandDT_LOG_FILEenvironment variables -
⏱️ Includes a
dt_timerdecorator andPerformanceTimercontext 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e42e3694ea8063d82d201e8f19a3b5be56c2213319aaba7e90d4a154c0fd57c
|
|
| MD5 |
6e253373a4ad2e0ca504370f2b9af44a
|
|
| BLAKE2b-256 |
27485a4355364eeb74714b0a48fca1e96cda52fe6957d710571d8edf2d517bbc
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d29650bb6b5519648cf0b3cba0136ec40e12755a7139c3173fc66a73b29b9707
|
|
| MD5 |
2403f93a1bd40b927da66839324cb41f
|
|
| BLAKE2b-256 |
0b216dd7d2e55cdd44e5ba4e129ba0e775da4b360b5bcd629913c140b508fa61
|