A colored logger with context injection support for Python applications.
Project description
Colored Context Logger
A generic, easy-to-use logging library supporting:
- Colored console output (via
coloredlogs). - Context injection: Add global context (e.g.,
session_id,config_name) to all log records automatically. - File logging: Easy attachment of file handlers.
- Function tracing:
@log_callsdecorator to log function entry, exit, arguments, and execution time.
Installation
pip install colored-context-logger
Usage
1. Basic Setup & Context
from vibe_logger import setup_logger, GlobalLogContext, log_calls
# Setup Logger
logger = setup_logger(name="my_app", level="DEBUG")
# Set Global Context (will appear in all logs)
GlobalLogContext.update({"user": "alice", "request_id": "12345"})
logger.info("Processing request")
# Output: 2025-01-01 12:00:00 INFO my_app ... user=alice request_id=12345 Processing request
2. File Logging
You can easily attach file handlers to your logger.
from vibe_logger import attach_file_handler
# Method A: Auto-generated filename based on context
# If 'session' is in GlobalLogContext, it uses that for the filename.
GlobalLogContext.update({"session": "main_process"})
log_path = attach_file_handler(logger_name="my_app", log_dir="logs")
print(f"Logging to: {log_path}")
# Example: logs/main_process_20250101.log
# Method B: Specific filename
attach_file_handler(
logger_name="my_app",
log_dir="logs",
filename="error.log",
level="ERROR" # Only log errors to this file
)
3. Function Decorator
@log_calls()
def calculate(x, y):
return x + y
calculate(1, 2)
# Output:
# ➡️ calculate Start (1, 2)
# ⬅️ calculate End 0.0001s Ret: int
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 vibe_colored_logger-0.1.5.tar.gz.
File metadata
- Download URL: vibe_colored_logger-0.1.5.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85a762730a1490387fc3d2784a068eb2de2878cc3f844477677b7d9e02fed229
|
|
| MD5 |
10c82f40401a495c9d88cefcb8e753c2
|
|
| BLAKE2b-256 |
10fb864567b7b2848cbd994431fb87b4cc6f7151c6a4ca80f46ce35dd951588e
|
Provenance
The following attestation bundles were made for vibe_colored_logger-0.1.5.tar.gz:
Publisher:
pypi-vibe-colored-logger.yaml on jasoft/pythonlib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vibe_colored_logger-0.1.5.tar.gz -
Subject digest:
85a762730a1490387fc3d2784a068eb2de2878cc3f844477677b7d9e02fed229 - Sigstore transparency entry: 794160288
- Sigstore integration time:
-
Permalink:
jasoft/pythonlib@dbb773c9251e1c1d0faf5b802da8e6c54abc862d -
Branch / Tag:
refs/tags/vibe-logger-v0.1.5 - Owner: https://github.com/jasoft
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-vibe-colored-logger.yaml@dbb773c9251e1c1d0faf5b802da8e6c54abc862d -
Trigger Event:
push
-
Statement type:
File details
Details for the file vibe_colored_logger-0.1.5-py3-none-any.whl.
File metadata
- Download URL: vibe_colored_logger-0.1.5-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a472999c6d320ec1c5d4159603e31d0e9b1122d932204e7d1f933b683e5e34da
|
|
| MD5 |
aef1363b2be660a5f02635510a903289
|
|
| BLAKE2b-256 |
516c9c2ef2f7d16f958d65228279ade259bbfbb11c7ec069036021aa8af52683
|
Provenance
The following attestation bundles were made for vibe_colored_logger-0.1.5-py3-none-any.whl:
Publisher:
pypi-vibe-colored-logger.yaml on jasoft/pythonlib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vibe_colored_logger-0.1.5-py3-none-any.whl -
Subject digest:
a472999c6d320ec1c5d4159603e31d0e9b1122d932204e7d1f933b683e5e34da - Sigstore transparency entry: 794160343
- Sigstore integration time:
-
Permalink:
jasoft/pythonlib@dbb773c9251e1c1d0faf5b802da8e6c54abc862d -
Branch / Tag:
refs/tags/vibe-logger-v0.1.5 - Owner: https://github.com/jasoft
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-vibe-colored-logger.yaml@dbb773c9251e1c1d0faf5b802da8e6c54abc862d -
Trigger Event:
push
-
Statement type: