Skip to content

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.

License

Notifications You must be signed in to change notification settings

Kesha123/python-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Logger

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.

Install

pip install git+https://github.com/Kesha123/python-logger.git@v<latest-release-tag-number>

Available Handlers

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

Use

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!")

Logger

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
  • True
  • False

HandlerLevel

Argument Type Default Value
stream StreamHandler None
file FileHandler None
mongodb FileHandler None

StreamHandler

Argument Type Description Default Value Available Values
level int Logging level DEBUG
  • logging.DEBUG
  • logging.INFO
  • logging.WARNING
  • logging.ERROR
  • logging.CRITICAL

FileHandler

Argument Type Description Default Value Available Values
file str Files where logs are stored. logs.log
level int Logging level DEBUG
  • logging.DEBUG
  • logging.INFO
  • logging.WARNING
  • logging.ERROR
  • logging.CRITICAL

MongoDBHandler

Argument Type Description Default Value Available Values
level int Logging level DEBUG
  • logging.DEBUG
  • logging.INFO
  • logging.WARNING
  • logging.ERROR
  • logging.CRITICAL
connection_string str Mongo Database connection string None
database str Mongo Database Name None
collection str Mongo Database Collection Name None

Color Scheme

Level Text Colored Text
DEBUG debug debug
INFO info info
WARNING warning warning
ERROR error error
CRITICAL critical critical

Logging Levels

Level Code
NOTSET 0
DEBUG 10
INFO 20
WARNING 30
ERROR 40
CRITICAL 50

About

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages