Welcome to NestLog
Fancy tree logger for excellent shell output. Uses the Click library for shell colors. Unlike the typical logger, the concept of “level” in this logger refers to the depth of the tree. So the higher the level, the deeper the tree will display. The logger has three methods, okay, warn, and fail. Each correspond to a color.
>>> logger.okay('downloading configuration file')
>>> with logger('download'):
>>> logger.okay('connect to server')
Installation
nestlog is available on the public pypi.
python -m pip install nestlog
Use the different methods to indicate status.
from nestlog import logger
with logger('starting application'):
try:
# load files
except Exception:
# ...
logger.fail('loading files')
else:
logger.okay('loading files')
if something:
logger.okay('step completed')
else:
logger.warn('step completed')
Use the nestlog loggers with statement to control the depth of the log.
from nestlog import logger
with logger('starting application'):
with logger('starting section 1'):
logger.okay('doing something important')
logger.okay('doing something else important')
with logger('starting section 1'):
logger.okay('doing something important')
logger.okay('doing something else important')
You can set the verbose parameter with an int to specify the depth of the tree to log:
import nestlog
logger = nestlog.NestLogger(1)
with logger('starting application'):
with logger('starting section 1'):
logger.okay('doing something important')
logger.okay('doing something else important')
with logger('starting section 1'):
logger.okay('doing something important')
logger.okay('doing something else important')
# verbose = 1
>>> starting application
├──[starting section 1]
├──[starting section 1]
└──[done] 3.4e-05
# verbose = 2
>>> starting application
|
├─────[starting section 1]
| ├──[okay] doing something important
| ├──[okay] doing something else important
| └──[done] 0.001594
|
├─────[starting section 1]
| ├──[okay] doing something important
| ├──[okay] doing something else important
| └──[done] 0.002071
|
└──[done] 0.002801