python logging on steroids, lightweight and convenient
Project description
nanolog
Life is too short. Use nanolog to make logging and printing simpler!
nanolog features a convenient logger API built on top of python’s builtin logging.
The library also ships with many printing utilities. Python 3 only.
Installation:
pip install nanolog
nanolog.Logger
import nanolog as nl
logger = nl.Logger.create_logger(
'main',
stream='out',
level='debug',
)
logger.info('my', 3, 'world', 1/16.) # just like print
# >>> my 3 world 0.0625
logger.warningfmt('{}, we are {:.3f} miles from {planet}',
'Houston', 17/7, planet='Mars') # just like str.format
# >>> Houston, we are 2.429 miles from Mars
Use a trailing number to indicate level, the larger the higher priority
logger.info7(...) # info level 7
logger.errorfmt8(...) # error level 8
Display a banner line or block
logger.infobanner3('my', 3, 'world', symbol='!', banner_len=16, banner_lines=3)
prints:
!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!! my 3 world !!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!
Of course, banner method also comes with a str.format version
logger.debugbannerfmt(
'{3}&{0}&{2}&{1}', 'a', 'b', 'c', 'd',
symbol='<*_*>', banner_len=16, banner_lines=6
)
displays:
<*_*><*_*><*_*><*_*><*_*> <*_*><*_*><*_*><*_*><*_*> <*_*><*_ d&a&c&b <*_*><*_ <*_*><*_*><*_*><*_*><*_*> <*_*><*_*><*_*><*_*><*_*> <*_*><*_*><*_*><*_*><*_*>
Logger config
TODO
Time formatting
TODO
Printing utililites
prettyprint
Better alternatives for the pprint module in python standard lib.
pprint: takes variable number of objects, just like print()
pprintstr: return string instead of printing to IO stream
pprintfmt: just like print('...'.format)
pprintfmtstr: return string instead of printing to IO stream
Convenient aliases:
original |
short |
---|---|
pprint |
pp |
pprintstr |
pps |
pprintfmt |
ppf |
pprintfmtstr |
ppfs |
TODO: talk about global configs
Print redirection context managers
PrintRedirection
PrintFile
PrintSuppress
PrintString
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
File details
Details for the file nanolog-0.1.1.tar.gz
.
File metadata
- Download URL: nanolog-0.1.1.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27d278a4decac9d066e28b8adbbe9f6eb986e62021196c4bd10bc83710bbb3af |
|
MD5 | b593b69c2bc627f1b86885e64b63ca29 |
|
BLAKE2b-256 | c8e9d6d72bf100a0763973116a40aad823bfa2965c1f2e7ed4d1db812e03cd8a |
File details
Details for the file nanolog-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: nanolog-0.1.1-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac27ecfd3e64d8e515dcaece3b3bec9a4bfc40a6965359633db485e17ce534ba |
|
MD5 | be0e63ac711152a5de5c9def05625be3 |
|
BLAKE2b-256 | 0d969b5c18152f50af60b6d1f3b8971548ac8728fd36831e5f47ea019860a2f3 |