Skip to main content

A lightweight, colorized Python terminal logger with auto exception capture and customizable format

Project description

Traceify

A lightweight, colorized Python terminal logger with auto exception capture, auto source-file detection, and a fully customizable log format.

Zero dependencies — uses only Python's standard library.


Installation

pip install Traceify

Quick Start

from Traceify import Traceify

log = Traceify("my_app")

log.debug("Starting up...")
log.info("Server running on port 8080")
log.warning("Memory usage above 80%")
log.error("Database connection failed")
log.critical("Disk full — shutting down!")

Output:

2026-04-13 11:00:00  [DEBUG   ]  [my_app]  Starting up...  @app.py
2026-04-13 11:00:00  [INFO    ]  [my_app]  Server running on port 8080  @app.py
2026-04-13 11:00:00  [WARNING ]  [my_app]  Memory usage above 80%  @app.py
2026-04-13 11:00:00  [ERROR   ]  [my_app]  Database connection failed  @app.py
2026-04-13 11:00:00  [CRITICAL]  [my_app]  Disk full — shutting down!  @app.py

Features

✅ Auto Exception Capture

Call any log method inside an except block — the active exception is automatically appended. No extra code needed.

try:
    result = 10 / 0
except ZeroDivisionError:
    log.error("Math operation failed")
# Output: ... [ERROR   ]  [my_app]  Math operation failed  (ZeroDivisionError: division by zero)  @app.py

✅ Auto Source File Detection

Every log line automatically shows which file it came from — useful when logs from multiple files appear together.

2026-04-13 11:00:00  [INFO    ]  [api]  Request received  @routes.py
2026-04-13 11:00:00  [ERROR   ]  [db]   Query failed      @database.py

✅ Customizable Format

Choose exactly which fields to show and in what order using the fmt parameter.

Available fields: "timestamp", "level", "name", "message", "exception", "file"

# Only level, message, and source file
log = Traceify("app", fmt=["level", "message", "file"])
log.info("Compact output")
# → [INFO    ]  Compact output  @app.py

# Only timestamp and message
log = Traceify("app", fmt=["timestamp", "message"])
log.warning("Something happened")
# → 2026-04-13 11:00:00  Something happened

✅ Runtime Format & Level Changes

log.set_format(["level", "message", "file"])   # change format on the fly
log.set_level("WARNING")                        # suppress DEBUG and INFO

✅ Log Level Filtering

Set a minimum level — messages below it are silently suppressed.

log = Traceify("auth", level="WARNING")  # only WARNING / ERROR / CRITICAL shown
log.debug("This won't appear")
log.warning("This will appear")

API Reference

Traceify(name, level, fmt)

Parameter Type Default Description
name str "root" Label shown in every log line
level str "DEBUG" Minimum log level to display
fmt list all fields Ordered list of fields to include

Logger methods

Method Description
log.debug(msg) Detailed diagnostic info
log.info(msg) General operational events
log.warning(msg) Unexpected but recoverable
log.error(msg) A serious problem
log.critical(msg) Fatal error
log.set_level(level) Change minimum level at runtime
log.set_format(fmt) Change field list at runtime

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

traceify-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

traceify-0.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: traceify-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for traceify-0.1.0.tar.gz
Algorithm Hash digest
SHA256 83346a6e42d28d3a64da3e7256a2e316215caa3ea9248ad3d3bf429dad4f866b
MD5 63117b50be4f9b5e01c58a95ef01135a
BLAKE2b-256 2edf87083bffd090406ecfb69cdbf786cf3faa4962fa93090d042c4c35e98ab6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceify-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for traceify-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a15c7d1a142cd9159905c8b4903b68ef5f35b10a4b3246c50dbd883f8f48fae
MD5 f9a84c5166edb0019084c280c99fca0b
BLAKE2b-256 224706cb3a5857b846e00b279415aa768b6c0035e301be330b2b0e0dccb93210

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