A bullet-train style Python logging utils.
Project description
logging-bullet-train
A bullet-train style Python logging utility with colorful, emoji-enhanced log messages.
Documentation: https://allen2c.github.io/logging-bullet-train/
Features
- Colorful log levels and readable segment separators.
- ISO-8601 timestamps with
zoneinfotimezone support. - 45 built-in emoji themes plus custom theme mappings.
- Idempotent logger setup to avoid duplicate log lines.
- Configurable stream, color mode, propagation, and visible format sections.
Installation
pip install logging-bullet-train
For development:
poetry install --with dev
Usage
import logging
import logging_bullet_train as lbt
logger = lbt.set_logger("my_logger", level=logging.DEBUG)
logger.debug("debug message")
logger.info("info message")
logger.warning("warning message")
logger.error("error message")
logger.critical("critical message")
logger.log(1, "unknown message")
Sample output:
2026-04-27T08:08:12+00:00 🔎 DEBUG my_logger:8 debug message
2026-04-27T08:08:12+00:00 💡 INFO my_logger:9 info message
2026-04-27T08:08:12+00:00 ⭐ WARNING my_logger:10 warning message
Configuration
import logging
import sys
from logging_bullet_train import set_logger
logger = set_logger(
"app",
level="INFO",
theme="rocket",
color="auto",
stream=sys.stderr,
timezone="Asia/Taipei",
show_datetime=True,
show_logger_name=True,
show_lineno=True,
propagate=False,
)
Logging defaults to stderr, which is the usual choice for logs because it keeps
program output on stdout clean for shell pipelines.
Themes
Use a named theme:
logger = set_logger("app", theme="terminal")
Built-in themes:
from logging_bullet_train import level_emojis
print(sorted(level_emojis))
Use a custom theme mapping:
import logging
logger = set_logger("app", theme={logging.INFO: "ok"})
Custom themes are merged with the default theme, so you only need to override the levels you care about.
Color
set_logger("app", color=True)
set_logger("app", color=False)
set_logger("app", color="auto")
set_logger("app", color="always")
set_logger("app", color="never")
"auto" enables color only for TTY streams and respects the NO_COLOR
environment variable.
Format Sections
set_logger(
"app",
show_datetime=False,
show_logger_name=False,
show_lineno=False,
)
Logger Attributes
set_logger("app", propagate=False, disabled=False)
set_logger() also avoids adding duplicate bullet-train handlers when called
more than once for the same logger and stream. Pass replace_handlers=True to
replace existing bullet-train handlers.
Manual Handler Setup
import logging
from logging_bullet_train import BulletTrainFormatter
handler = logging.StreamHandler()
handler.setFormatter(BulletTrainFormatter(theme="weather", color="auto"))
logger = logging.getLogger("manual")
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)
Documentation
The documentation site is built with MkDocs Material.
Serve it locally:
poetry run mkdocs serve
Build it strictly:
poetry run mkdocs build --strict
GitHub Actions builds and deploys GitHub Pages when main is pushed.
License
MIT. See 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
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 logging_bullet_train-0.4.0.tar.gz.
File metadata
- Download URL: logging_bullet_train-0.4.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.12.13 Darwin/25.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98e9b55e2e42764519a5030e6b0b4eee984c652af47a368580be89f23343959d
|
|
| MD5 |
7344dc0d66f9ad7dc93439e37b7c2408
|
|
| BLAKE2b-256 |
7ed0599f6b188b2034b408d14e8d369cbc603465b00904f8190454c01ce4e6f8
|
File details
Details for the file logging_bullet_train-0.4.0-py3-none-any.whl.
File metadata
- Download URL: logging_bullet_train-0.4.0-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.12.13 Darwin/25.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
529cc8935566c31536877410aa8d14291d0cb82445a19776c6b2f0ede246caf4
|
|
| MD5 |
486835e132559ba2aae995fb4206b9f5
|
|
| BLAKE2b-256 |
420040932aea742aba10135c197e953e23c71bee54b5a9f07bd3ab5c6e09e016
|