Small modern colored logging library
Project description
ezlog
Modern, simple in use, fast, colored logging library for python.
- Formatting support
- Stdout\Stderr\File handlers
- Easy to use & add custom handlers
- Colored and customizable
Installation
You can install this via pip (Windows):
pip install ezloglib
And also for linux systems:
pip3 install ezloglib
Read more about this on the documentation
Examples
Example from the documentation.
File: examples/presentation.py
import ezlog
import math
# declare stdout handler with log level - debug
sout_handler = ezlog.StdoutHandler(log_level='debug')
# initialize main logger
main_logger = ezlog.Logger('Main', handlers=[sout_handler])
# examples of the default log levels
main_logger.debug('This is {} message', 'debug')
main_logger.exception('This is {} message', 'exception')
main_logger.info('This is {} message', 'info')
main_logger.warning('This is {} message', 'warning')
main_logger.error('This is {} message', 'error')
main_logger.critical('This is critical message')
# pretty formatting + colored types
main_logger.debug('Int: {} List: {} Dict: {}', 13, [1, 2, 3], {'hello': 'world'})
main_logger.exception('Tuple: {} Bool: {} Bytes: {}', ('hello', 'world'), True, b'whois?')
main_logger.info('Float: {}', math.pi)
main_logger.warning('Exception (color): {}', NameError("name 'abc' is not defined"))
# example of the formatting
main_logger.info('{:<20}--{:>19}', 'pi is', f'{math.pi:.2f}')
# example exception logging
try:
printt('Hello, world!')
except Exception as e:
# NOTE: You can use also debug, critical and other log levels to print exception
main_logger.exception('Exception example', exception=e)
main_logger.info('It is continue work')
File: examples/groups_filelogging.py
import ezlog
# declare stdout handler with log level - debug
file_handler = ezlog.FileHandler('example.log', log_level='debug')
sout_handler = ezlog.StdoutHandler(log_level='info') # recommended: exception log level as default
# initialize example groups
example_group = ezlog.LoggerGroup('Example', handlers=[sout_handler, file_handler])
groups_group = ezlog.LoggerGroup('Groups', parent=example_group)
main_logger = ezlog.Logger('Main', group=groups_group)
# examples of the default log levels
main_logger.debug('This is {} message', 'debug')
main_logger.exception('This is {} message', 'exception')
main_logger.info('This is {} message', 'info')
main_logger.warning('This is {} message', 'warning')
main_logger.error('This is {} message', 'error')
main_logger.critical('This is critical message')
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
ezloglib-1.0.1.tar.gz
(10.4 kB
view details)
Built Distribution
ezloglib-1.0.1-py3-none-any.whl
(11.0 kB
view details)
File details
Details for the file ezloglib-1.0.1.tar.gz
.
File metadata
- Download URL: ezloglib-1.0.1.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e571399db50d61a83588802c8911cc2d0e8545fb4f37d5a9d6f5286bf2e6c9d6 |
|
MD5 | d27576fd35f60554dc3b1ab54ddb45dd |
|
BLAKE2b-256 | 0d2c4b51a550b825718d4926ca69856ed778bc04aaa11931dae62b9a55948899 |
File details
Details for the file ezloglib-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: ezloglib-1.0.1-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc380f10a99dbf19d7f5368724243fdb3486de45e1c21eeb86abbf5bb588fdcb |
|
MD5 | 5d47c155b01325bd68d5d5626fe9e7fa |
|
BLAKE2b-256 | 33b861875e2b4ddd44a36c7ddaf5eb29aceb39d029d82ad692923cccdb17425e |