Skip to main content

A tiny logger tool for Python

Project description

nanologger

nanologger is a tiny logger made with Python.

It includes basic functionality such as

  1. A basic log
  2. Warning logs
  3. Fatal logs
  4. Success logs

This tiny package also includes time format editing and enabling/disabling colors

Warning: Windows does not support color in console, so it is automatically disabled

Example code:

import nanologger as log

print("The first four logs will be printed, and will not exit on Fatal call")
log.Log("Database service is up")
log.Warning("File not found, using default directory")
log.Fatal("Cannot connect to server", exit = False)
log.Success("Operation Complete\n")

print("Next three four will be printed without color")
log.hasColor = False
log.Log("Database service is up")
log.Warning("File not found, using default directory")
log.Fatal("Cannot connect to server", exit = False)
log.Success("Operation Complete\n")

print("Next three four will be printed without timestamp")
log.hasColor = True
log.hasTimestamp = False
log.Log("Database service is up")
log.Warning("File not found, using default directory")
log.Fatal("Cannot connect to server", exit = False)
log.Success("Operation Complete\n")

print("Next three logs will be printed in a different time format, and exit on Fatal call")
log.hasTimestamp = True
log.hasColor = True
log.timeFormat = "%Y-%m-%d"
log.Log("Database service is up")
log.Warning("File not found, using default directory")
log.Fatal("Cannot connect to server")
log.Success("Operation Complete")

Methods:

  1. Log prints a log with a timestamp
  2. Warning prints a warning with timestamp
  3. Fatal prints a fatal log (terminates program if appropeiate value set)
  4. Success prints a success log

Variables:

  1. timeFormat is a string, supports regular Python timestamps default: "%d-%m-%Y %H:%M:%S"
  2. hasColor is a boolean that sets/removes color from the logs default: True
  3. hasTimestamp is a boolean that sets/removes the timestamp default: True

Installation

Install the package by running

pip install nanologger

Import it with

import nanologger

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

nanologger-1.0.3.tar.gz (2.4 kB view hashes)

Uploaded Source

Built Distribution

nanologger-1.0.3-py3-none-any.whl (3.2 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