Skip to main content

Simple python log helper

Project description

Overview

Description

  • Logging can be a little daunting. This makes things a little easier.

Features

  • Simple logger set up
  • Automatically print log levels to terminal in color for easier debugging
  • Promotes logging DURING development, not after! Reduce your tech debt.

Log Levels

  • 1 = DEBUG (green)
  • 2 = INFO (cyan)
  • 3 = WARNING (yellow)
  • 4 = ERROR (magenta)
  • 5 = CRITICAL (red)

Syntax

from logg3r import Log

#initialize logger
#OPTIONAL! this initializes the file handler format, it defaults to a simple TIME | LEVEL | MESSAGE format
#formatter='{} | %(levelname)s | %(message)s '.format(datetime.datetime.utcnow().replace(microsecond=0))
#rotation=filename,when='d',interval=30,backupCount=1,encoding=None,delay=False,utc=True,atTime=datetime.time(4, 0, 0)

logger = Log(log_path="./path/to/logs/",	#REQUIRED: sets the path of the log file
			#REQUIRED: sets the name of the log file
			name="test_log",				
			#REQUIRED: sets log level to be stored in file and printed to console
			level=1	
			#OPTIONAL: defaults to above format, any valid logger format is accepted
			#,formatter=formatter,
			#OPTIONAL: defaults to 30 days of retention with (1) log overflow file (log.1)
			#rotation=rotation,
			#OPTIONAL: elect to NOT create log path like if using /var/log on linux)
			#create_path=False
			)				

logger.log("test DEBUG message",1)
logger.log("test INFO message",2)
logger.log("test WARNING message",3)
logger.log("test ERROR message",4)
logger.log("test CRITICAL message",5)

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logg3r-1.0.tar.gz (3.6 kB view hashes)

Uploaded Source

Built Distribution

logg3r-1.0-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page