BTech Logger
A lightweight, dependency-free Python logging utility with configurable logging levels, automatic log files, stack traces, and exception handling.
BTech Logger uses only Python's standard library.
Features
- Zero third-party dependencies
- Five logging levels: fatal, error, warn, log, and verbose
- Configurable logging verbosity
- Timestamped log messages
- Automatic log directory creation
- Date-based log filenames
- Optional console output
- Optional call-stack logging
- Exception traceback support
- Built-in exception raising
- Shorthand logging methods
Installation
Install using pip:
pip install btech-logger
Quick Start
from btech_logger import Logger
logger = Logger()
logger.log("Application started")
logger.warn("This is a warning")
logger.error("An error occurred")
logger.fatal("A fatal condition occurred")
By default, Logger writes messages to a log file.
Configuration
logger = Logger(
log_level="log",
date_format="%d/%m/%Y - %H:%M:%S",
do_print=True,
show_stack_trace=False
)
Parameters
| Parameter | Default | Description |
|---|---|---|
log_level |
"log" |
Minimum logging severity |
date_format |
"%d/%m/%Y - %H:%M:%S" |
Timestamp format |
do_print |
False |
Print logged messages to the console |
show_stack_trace |
False |
Include call stacks in log messages |
Logging Levels
Logger supports five levels, ordered from highest to lowest severity:
| Level | Method | Shorthand |
|---|---|---|
| Fatal | fatal() |
f() |
| Error | error() |
e() |
| Warning | warn() |
w() |
| Log | log() |
l() |
| Verbose | verbose() |
v() |
The configured logging level determines which messages are recorded.
For example:
logger = Logger(log_level="warn")
This records only:
- Fatal messages
- Error messages
- Warning messages
Log and verbose messages are ignored.
Exception Handling
Logger can log a message and raise an exception.
logger.error(
"Invalid configuration",
ValueError
)
This writes the error message and raises:
ValueError("Invalid configuration")
The exception class must inherit from BaseException.
Logging Existing Exceptions
try:
result = 10 / 0
except ZeroDivisionError as exc:
logger.error(
"Division failed",
exc=exc
)
This records the exception traceback alongside the error message.
Stack Traces
Stack traces can be enabled for individual messages:
logger.error(
"Something unexpected happened",
show_stack=True
)
Or globally:
logger = Logger(show_stack_trace=True)
Stack traces help identify where logging calls originated.
Log Files
Logger automatically creates a logs directory.
Log filenames use the date on which the Logger instance was created.
Example:
logs/
└── 2026-10-20-log.txt
Example log contents:
20/10/2026 - 14:32:01 | [LOG] Application started
20/10/2026 - 14:32:05 | [WARN] This is a warning
20/10/2026 - 14:32:07 | [ERROR] An error occurred
Note: The current implementation does not automatically switch log files at midnight.
Dependencies
BTech Logger has no third-party runtime dependencies.
It uses only:
ostracebackdatetime
All three are included in Python's standard library.
License
Distributed under the MIT License.
See LICENSE for details.
Metadata
Release files for btech-logger 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| btech_logger-1.0.0.tar.gz | 4.9 kB | Without provenance | Details for btech_logger-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| btech_logger-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for btech_logger-1.0.0-py3-none-any.whl |
Total release size: 10.2 kB
Release files / btech_logger-1.0.0.tar.gz
| Download URL | btech_logger-1.0.0.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5d7bd2c938f037eb630f5e315cdd2f074a49b073cb7d16a1493ef889accbbff
|
|
BLAKE2b-256 checksum How to use checksums |
07071e91a4d11d23b641e68f72dfd6d74280e4843dbb5dcdb939a4e69b7396c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / btech_logger-1.0.0-py3-none-any.whl
| Download URL | btech_logger-1.0.0-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a189847555d525543b3b72971b98dc605e47717c0796c164c93b273043c3223e
|
|
BLAKE2b-256 checksum How to use checksums |
ec8e8ebfb5c5f958059ea20499415ecec1eee1fa9d1d416343f9cdc326be3cd2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for btech-logger 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.