Lightweight Python logger with timestamped file output, caller stack tracing, and working-directory-scoped file utilities
Project description
ntnlog
Lightweight Python logger with timestamped file output, caller stack tracing, and working-directory-scoped file utilities. Next-To-Nothing setup — just import and log.
Features
- Caller stack tracing: Automatically records where in your code a log came from
- Timestamped file output: Logs written to daily files with no configuration required
- File utilities: Safe, working-directory-scoped file operations with error handling
- Thread-safe: File writes are protected by a lock
Installation
pip install ntnlog
Quick Start
from ntnlog import Logger
log = Logger()
log("Application started")
log("Important message", print_to_console=True)
log("Debug info", print_to_console=True, console_message="DEBUG: Debug info")
# Enable detailed call-stack tracing
log.enable_log_tracing(True)
log("Traced message")
# Named loggers — useful when multiple instances log to the same file
app_logger = Logger(name="app")
worker_logger = Logger(name="worker")
# Output: [2026-05-13 15:46:34][app][main.py:12] message
# [2026-05-13 15:46:34][worker][worker.py:8] message
# Custom log directory
log = Logger(log_dir="my_logs")
# Project-aware frame filtering
log = Logger(project_dir="/path/to/project")
Configuration
from ntnlog.ntn_config import GLOBAL_LOGGING_ENABLED, GLOBAL_LOG_TRACING_ENABLED
GLOBAL_LOGGING_ENABLED: Master on/off switch for all loggers (default:True)GLOBAL_LOG_TRACING_ENABLED: Master on/off switch for tracing (default:True)
Per-instance controls:
log.enable_logging(False) # disable this logger
log.enable_log_tracing(True) # enable tracing for this logger
Modules
Logger (ntn_logging.py)
Main logging class. Writes timestamped entries to ./logs/<date>_logging.txt and optionally traces the full call stack to show exactly which file and line triggered the log.
File Utilities (ntn_file_utils.py)
Path and file verification scoped to the working directory:
file_verify_path(base, directory)— confirms a directory exists within the working dirfile_verify_file(base, filename, operator)— validates a file for read/write/execute
Utils (ntn_utils.py)
Working-directory-scoped path helpers with a clean exception-based API:
ntnlog.utils.get_working_dir()— returns the current working directoryntnlog.utils.resolve_path(path, must_exist=False)— resolves a path within the working directory, raisesValueErrorif it escapes
Configuration (ntn_config.py)
Global flags controlling logging and tracing behaviour across all logger instances.
Development
pip install -e ".[dev]"
pytest
pytest -v
pytest tests/test_ntn_logging.py
License
MIT
Author
Nathan T Nguyen
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 ntnlog-0.3.0.tar.gz.
File metadata
- Download URL: ntnlog-0.3.0.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b632e482ad6abb8f7bdebdf19513202daa8b2bd4fa3f767a5032fde24b33efbd
|
|
| MD5 |
5ee272274674ebbec5817982433bdeb6
|
|
| BLAKE2b-256 |
7770e1d258b66901efb4b6a0ca6c8f4476e7232c0b0014552cd0c60a0155aba0
|
Provenance
The following attestation bundles were made for ntnlog-0.3.0.tar.gz:
Publisher:
publish.yml on NhatNguyen5/ntnlog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ntnlog-0.3.0.tar.gz -
Subject digest:
b632e482ad6abb8f7bdebdf19513202daa8b2bd4fa3f767a5032fde24b33efbd - Sigstore transparency entry: 1565967567
- Sigstore integration time:
-
Permalink:
NhatNguyen5/ntnlog@f3d29cf3ebb746f7a2a0d0716a9732f15d34c941 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/NhatNguyen5
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f3d29cf3ebb746f7a2a0d0716a9732f15d34c941 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ntnlog-0.3.0-py3-none-any.whl.
File metadata
- Download URL: ntnlog-0.3.0-py3-none-any.whl
- Upload date:
- Size: 8.7 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 |
c239f37b362da009bf5cf2051f4666914f97bf2319913af115753dd26867a676
|
|
| MD5 |
71c3b0dacf92eba1ae2668c0ebf7d8c7
|
|
| BLAKE2b-256 |
9bf5d1b10c470a8ee50b57141a1a572d6b0e92777a2d26053dbf35afee87a331
|
Provenance
The following attestation bundles were made for ntnlog-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on NhatNguyen5/ntnlog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ntnlog-0.3.0-py3-none-any.whl -
Subject digest:
c239f37b362da009bf5cf2051f4666914f97bf2319913af115753dd26867a676 - Sigstore transparency entry: 1565967572
- Sigstore integration time:
-
Permalink:
NhatNguyen5/ntnlog@f3d29cf3ebb746f7a2a0d0716a9732f15d34c941 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/NhatNguyen5
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f3d29cf3ebb746f7a2a0d0716a9732f15d34c941 -
Trigger Event:
release
-
Statement type: