Python logging library with color output, progress bars, and spinners
Project description
LucidLogger
A Python library for standardized terminal logging with ANSI color support, progress bars, spinners, and timed rotating file output.
Features
- Colored log output per level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
- Custom log levels with configurable colors
- Inline progress/loading bars that coexist with log output
- Indeterminate spinner for operations with unknown duration
- Auto-resizing progress bars based on terminal width
- Cross-platform (Windows CMD, PowerShell, Bash)
- Timed rotating file handler with dated filenames
- File logs strip ANSI — clean output for log aggregators
Installation
pip install lucid-logger
Quick Start
from lucid_logger import get_logger
logger = get_logger("app")
logger.info("Server started")
logger.warning("High memory usage")
logger.error("Failed to connect")
get_logger creates a LucidLogger with a colored stream handler and a timed rotating file handler in one call.
With a Progress Bar (wrap)
from lucid_logger import get_logger, LucidLoadingBar
logger = get_logger("app")
bar = LucidLoadingBar(name="import")
logger.add_loading_bar(bar)
for item in bar.wrap(items, prefix="Importing"):
process(item)
logger.info(f"Processed {item}")
With a Spinner
from lucid_logger import get_logger, LucidSpinner
logger = get_logger("app")
spinner = LucidSpinner(name="fetch", prefix="Fetching data")
logger.add_spinner(spinner)
with spinner:
result = requests.get(url)
logger.info("Fetch complete")
Manual setup (advanced)
from lucid_logger import LucidLogger
logger = LucidLogger(name="app", log_lowest_level=10, colored_logs=True)
logger.basic_config()
API Reference
get_logger(name, ...)
Factory function — the recommended way to create a logger.
| Parameter | Type | Default | Description |
|---|---|---|---|
name |
str |
— | Logger name |
level |
int |
logging.DEBUG |
Minimum log level |
colored |
bool |
True |
Enable ANSI color on stream output |
log_dir |
str |
'./logs/' |
Directory for rotating log files |
stream |
bool |
True |
Attach a stream handler to stdout |
file |
bool |
True |
Attach a rotating file handler |
LucidLogger
Extends logging.Logger.
| Parameter | Type | Description |
|---|---|---|
name |
str |
Logger name |
log_lowest_level |
int |
Minimum log level (e.g. 10 = DEBUG) |
colored_logs |
bool |
Enable ANSI color output |
Methods:
| Method | Description |
|---|---|
basic_config() |
Attach default stream and file handlers |
add_loading_bar(bar) |
Register a LucidLoadingBar with the stream handler |
get_loading_bar(name) |
Retrieve a registered bar by name |
add_spinner(spinner) |
Register a LucidSpinner with the stream handler |
add_logging_level(level_name, level_num, color) |
Register a custom log level with a color |
LucidLoadingBar
A terminal progress bar that renders inline with log output.
| Parameter | Type | Default | Description |
|---|---|---|---|
name |
str |
— | Unique identifier |
iterable |
iterable |
None |
Collection to iterate over |
prefix |
str |
'Loading...' |
Label shown before the bar |
suffix |
str |
'' |
Label shown after the bar |
colored_logs |
bool |
True |
Enable ANSI color |
fill |
str |
█ |
Fill character |
decimals |
int |
1 |
Decimal places on the percent |
length |
int |
100 |
Bar width in characters |
Methods:
| Method | Description |
|---|---|
init_bar(iterable, prefix, total) |
Start the bar, auto-sizes to terminal width |
wrap(iterable, prefix) |
Iterate over iterable while auto-advancing the bar |
progress_bar() |
Advance progress by one step |
finish_loading() |
Mark the bar complete and clear it |
get_bar() |
Return the current formatted bar string |
LucidSpinner
An indeterminate progress indicator that animates in place on a background thread. Log output from LucidLogger will pause the spinner frame, write the log line, then let the spinner resume — no interleaving.
Uses Unicode braille frames (⠋ ⠙ ⠹ …) where supported, falls back to ASCII (| / - \).
| Parameter | Type | Default | Description |
|---|---|---|---|
name |
str |
— | Unique identifier |
prefix |
str |
'' |
Label shown before the spinner frame |
colored_logs |
bool |
True |
Enable ANSI color |
color |
str |
grey |
ANSI escape string for the spinner color |
interval |
float |
0.1 |
Seconds between frame advances |
Methods:
| Method | Description |
|---|---|
start() |
Begin animation on a daemon thread |
stop() |
Stop animation, clear the line, join the thread |
__enter__ / __exit__ |
Use as a context manager |
LucidStreamFormatter
Custom logging.Formatter that injects ANSI color codes per log level.
Levels below detailed_view_threshold omit the filename/line number from the output to keep routine logs terse. Warnings and above include the source location.
LucidTimedRotatingFileHandler
Extends TimedRotatingFileHandler. Rotates at midnight and names files by date (YYYY-MM-DD.log). Creates the log directory automatically if it does not exist.
| Parameter | Default | Description |
|---|---|---|
directory |
'./logs/' |
Output directory |
when |
'midnight' |
Rotation schedule |
file_extension |
'log' |
File extension |
Color Reference
Built-in named colors available for custom levels and bar/spinner segments:
| Name | Hex |
|---|---|
grey |
#C8C8C8 |
white |
#FFFFFF |
red |
#FF0000 |
yellow |
#FFFF00 |
green |
#009600 |
lime |
#00FF00 |
cyan |
#00FFFF |
blue |
#0000FF |
purple |
#000096 |
Custom Log Levels
from lucid_logger import get_logger, cyan
logger = get_logger("app")
logger.add_logging_level("TRACE", 5, cyan)
logger.trace("Entering request handler")
Log Output Format
Stream (colored):
[MM/DD/YYYY HH:MM:SS][LEVEL] message
[MM/DD/YYYY HH:MM:SS][WARNING][filename.py:42] message
File (plain):
[MM/DD/YYYY HH:MM:SS][INFO] message
[MM/DD/YYYY HH:MM:SS][ERROR][filename.py:42] message
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
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 lucid_logger-0.1.0.tar.gz.
File metadata
- Download URL: lucid_logger-0.1.0.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4696d689f611e758b74818daa7e3bf7cbe126d5ff83a6e3802b553ba612903fb
|
|
| MD5 |
6224c7a2c0399e0a5994ab26b8edae09
|
|
| BLAKE2b-256 |
23bd3f67eff77712f432a642a732fc14c0ed91eb05f2406d46d04d6634d46567
|
Provenance
The following attestation bundles were made for lucid_logger-0.1.0.tar.gz:
Publisher:
publish.yml on kevinthelago/LucidLogger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lucid_logger-0.1.0.tar.gz -
Subject digest:
4696d689f611e758b74818daa7e3bf7cbe126d5ff83a6e3802b553ba612903fb - Sigstore transparency entry: 1587098182
- Sigstore integration time:
-
Permalink:
kevinthelago/LucidLogger@0af54c23f8c3c322ded84d5985109d5c10c37239 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kevinthelago
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0af54c23f8c3c322ded84d5985109d5c10c37239 -
Trigger Event:
release
-
Statement type:
File details
Details for the file lucid_logger-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lucid_logger-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f66a5de75e89044c25496d23fd8b65ad11ccbb62108195f439ecc70c7d22e2c7
|
|
| MD5 |
49ccabec8bfcd336031a47dda3ddf032
|
|
| BLAKE2b-256 |
f2454bb0781e1027097eccf1c962bb4f0e4dc0dfc905421411a51e8988f3532d
|
Provenance
The following attestation bundles were made for lucid_logger-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on kevinthelago/LucidLogger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lucid_logger-0.1.0-py3-none-any.whl -
Subject digest:
f66a5de75e89044c25496d23fd8b65ad11ccbb62108195f439ecc70c7d22e2c7 - Sigstore transparency entry: 1587098429
- Sigstore integration time:
-
Permalink:
kevinthelago/LucidLogger@0af54c23f8c3c322ded84d5985109d5c10c37239 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kevinthelago
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0af54c23f8c3c322ded84d5985109d5c10c37239 -
Trigger Event:
release
-
Statement type: