indentlogger
indentlogger is an indentation-based logging library for Python, offering:
- Function-call tracing with nested indentation or ASCII-box style.
- Automatic decoration for modules/classes (no manual decorators needed).
- Optional replacement for
print(uselogger.info(), etc.).
Installation
From PyPI (once published):
pip install indentlogger
Quick Start
import logging
from indentlogger import IndentLogger, LogStyle
logger = IndentLogger()
logger.configure(
style=LogStyle.DASHED_BOX,
level=logging.DEBUG, # integer constant from logging
auto_log_level=logging.DEBUG # function entry/exit logs
)
@logger.log_entry_exit
def sample_function(x):
logger.info(f"Inside sample_function with x={x}")
sample_function(42)
When run, you’ll see ASCII “boxes” showing function entry, your log, and function exit.
Configuration
style:SIMPLE,DASHED_BOX,NO_PIPES, orDISABLED.level: Overall logging threshold (e.g.,logging.INFO,logging.DEBUG).auto_log_level: Logging level for function entry/exit calls.dash_line_length: (default60) ASCII-box width inDASHED_BOXmode.stream: Output stream (sys.stdout, file, etc.).
Example:
logger.configure(style=LogStyle.SIMPLE, level=logging.INFO, auto_log_level=logging.DEBUG)
Automatic Logging (No Decorators)
Auto-Log an Entire Module
If you don’t want to decorate each function, let the logger scan and decorate everything for you:
import logging
from indentlogger import IndentLogger, LogStyle
logger = IndentLogger()
logger.configure(style=LogStyle.DASHED_BOX, level=logging.DEBUG)
def fun1():
logger.info("Hello from fun1")
fun2(x=42)
def fun2(x):
logger.debug(f"fun2 got x={x}")
fun3(y=100)
fun4()
def fun3(y):
logger.info(f"fun3 got y={y}")
def fun4():
logger.info("Hello from fun4")
def fun5():
logger.info("Hello from fun5")
# No manual decorators here!
if __name__ == "__main__":
# This decorates all top-level functions except those starting with '_'
logger.auto_log_module(__name__)
fun1()
fun5()
Output:
.--fun1():--------------------------------------------------
|
│ Hello from fun1
│ .--fun2(x=42):------------------------------------------
│ |
│ │ fun2 got x=42
│ │ .--fun3(y=100):-------------------------------------
│ │ |
│ │ │ fun3 got y=100
│ │ '---------------------------------------------------
│ │ .--fun4():------------------------------------------
│ │ |
│ │ │ Hello from fun4
│ │ '---------------------------------------------------
│ '-------------------------------------------------------
'-----------------------------------------------------------
.--fun5():--------------------------------------------------
|
│ Hello from fun5
'-----------------------------------------------------------
Auto-Log a Class
class DataProcessor:
def process(self, data):
logger.info(f"Processing data={data}")
return data * 2
# Decorate all public methods
logger.auto_log_class(DataProcessor)
dp = DataProcessor()
dp.process("Hello")
Styles
- SIMPLE – Minimal indentation with
│, no explicit end line. - DASHED_BOX – ASCII boxes (top line:
.--fun(...):, bottom line:'--...). - NO_PIPES – Same as SIMPLE but uses spaces instead of
│. - DISABLED – Skips all logging entirely.
Example Outputs
SIMPLE
fun1():
│ fun2(num=123):
│ │ Inside fun2
│ fun3():
│ │ Inside fun3
DASHED_BOX
.--fun1():--------------------------------------
|
│ .--fun2(num=123):---------------------------
│ |
│ │ Inside fun2
│ |
│ '-------------------------------------------
│ .--fun3():----------------------------------
│ |
│ │ Inside fun3
│ |
│ '-------------------------------------------
|
'-----------------------------------------------
NO_PIPES
fun1():
fun2(num=123):
Inside fun2
fun3():
Inside fun3
DISABLED
No output at all.
License
MIT. Free to use, extend, and modify.
Metadata
Release files for indentlogger 0.1.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 |
|---|---|---|---|---|
| indentlogger-0.1.0.tar.gz | 5.4 kB | Without provenance | Details for indentlogger-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| indentlogger-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for indentlogger-0.1.0-py3-none-any.whl |
Total release size: 11.2 kB
Release files / indentlogger-0.1.0.tar.gz
| Download URL | indentlogger-0.1.0.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ee4b92d22aa45ad416ab517bedc0d3c2ee97ab281f77cbda3b14a22463fe3025
|
|
BLAKE2b-256 checksum How to use checksums |
a3b3539024e2080c2c806803cbf416d4cede3771b77b10738267db8ca91b41ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / indentlogger-0.1.0-py3-none-any.whl
| Download URL | indentlogger-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fb73d1ab695fc40f3e590b679464a237dc14aba9e14e4cde305bcad28bc984be
|
|
BLAKE2b-256 checksum How to use checksums |
e8e762459b445b89fa3eb2a8a0746f99ca50619019e1ee6d1e9577958ce00330
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Security for indentlogger 0.1.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.