Python Logger makes it easy to initialize a logger within the application scope. The Logger provides colorization and multiple ways to present and persist logs, including file and database storage. It allows you to set different logging levels for various handlers.
pip install git+https://github.com/Kesha123/python-logger.git@v<latest-release-tag-number>
Handler | HandlerLevel Argument Name | Description |
---|---|---|
Stream Handler | stream | Terminal and command line output |
File Handler | file | Persist logs in specified file |
MongoDB Handler | mongodb | Persist logs in specified Mongo database |
In order to use certain handler, pass it as an argument to HandlerLevel
import logging
from python_logger.Logger import Logger
from python_logger.handlers import *
handlers = HandlerLevel(stream=StreamHandler(level=logging.DEBUG))
logger = Logger(handlers=handlers)
logger.debug("Hello World!")
Argument | Type | Description | Default Value | Available Values |
---|---|---|---|---|
handlers | HandlerLevel | Defines available handlers | HandlerLevel(stream = StreamHandler()) |
|
colored_message | bool | Message is colored (green, cyan, e.t.c) | True |
|
Argument | Type | Default Value |
---|---|---|
stream | StreamHandler | None |
file | FileHandler | None |
mongodb | FileHandler | None |
Argument | Type | Description | Default Value | Available Values |
---|---|---|---|---|
level | int | Logging level | DEBUG |
|
Argument | Type | Description | Default Value | Available Values |
---|---|---|---|---|
file | str | Files where logs are stored. | logs.log | |
level | int | Logging level | DEBUG |
|
Argument | Type | Description | Default Value | Available Values |
---|---|---|---|---|
level | int | Logging level | DEBUG |
|
connection_string | str | Mongo Database connection string | None | |
database | str | Mongo Database Name | None | |
collection | str | Mongo Database Collection Name | None |
Level | Text Colored | Text |
---|---|---|
DEBUG | debug | debug |
INFO | info | info |
WARNING | warning | warning |
ERROR | error | error |
CRITICAL | critical | critical |
Level | Code |
---|---|
NOTSET | 0 |
DEBUG | 10 |
INFO | 20 |
WARNING | 30 |
ERROR | 40 |
CRITICAL | 50 |