Skip to main content

A simple python logger

Project description

spyl

a simple python logger

how to use

  • downloading the logger and installing required libraries

  1. download the logger and add to your project pip install spyl
  • personalizing the logger

  • when instantiating the Logger class you can configure a few parameters about the logger
  • logLevel, default to True - will the logger print out the level label e.g. if set to true: [12:00:00] [LEVEL] message if set to false [12:00:00] message
  • colorLevelText, default to True - will the level label get colored
  • quitWhenLogFatal, default to False - will the program quit when something with the fatal level is logged
  • colorText, default to True - will the message get colored
  • prefixBeforeTime, default to True, - if a prefix is set will it be displayed before the timestamp prefix [12:00:00] [LEVEL] message or after [12:00:00] prefix [LEVEL] message
  • warnLevel, an instance of LogLevel, default to LogLevel("WARN", Fore.YELLOW)
  • infoLevel, an instance of LogLevel, default to LogLevel("INFO", Fore.RESET)
  • debugLevel, an instance of LogLevel, default to LogLevel("DEBUG", Fore.WHITE)
  • errorLevel, an instance of LogLevel, default to LogLevel("ERROR", Fore.LIGHTRED_EX),
  • fatalLevel, an instance of LogLevel, default to LogLevel("FATAL", Fore.RED, isFatal=True)
  • prefix, default to "" - the prefix of the entry that is to be logged (see the prefixBeforeTime parameter)
  • logging default levels

  1. import the library using import spyl
  2. create an instance of the Logger class logger = spyl.Logger()
  • to log a warning use the logger.log_warning function

  • to log an info message use the logger.log_info function

  • to log a debug message use the logger.log_debug function

  • to log an error use the logger.log_error function

  • to log a fatal error use the logger.log_fatal function

  • adding additional custom levels

  1. import the library using import spyl
  2. import the colorama library using from colorama import Fore
  3. create an instance of the Logger class logger = spyl.Logger()
  4. create an instance of the LogLevel class customLevel = spyl.LogLevel("CUSTOM", Fore.GREEN, isFatal=False)
  • the LogLevel class has a few parameters which can be configured
  • name - the name/label of the level
  • color - the color in which the level will be logged
  • isFatal, default to False- is the level fatal (this in important because if it is and logger.quitWhenLogFatal is set to true and the level is fatal the program will exit when logged)
  1. log the custom level using logger.log("message", customLevel) or customLevel.log("message")

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

spyl-1.0.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spyl-1.0.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file spyl-1.0.1.tar.gz.

File metadata

  • Download URL: spyl-1.0.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for spyl-1.0.1.tar.gz
Algorithm Hash digest
SHA256 9f4cb7879c62fcbd54c146729fd2193708301254e232ac68e44707c663e52e30
MD5 0886c7e626aebe63ecbd3f8caa5b1f0f
BLAKE2b-256 40db91b2f551f897d050709d35b589242bc4f21a0c92af1c7bef08740e3b214f

See more details on using hashes here.

File details

Details for the file spyl-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: spyl-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for spyl-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b26506633420f110a95dc25eaa5e3e84c0ba9ffa165b177724a7efa52fecc637
MD5 5b3de99f3dff90cb84930114dcb541f8
BLAKE2b-256 7fe66059e01df2008f83e7da0b108ace77ebfe453d6285df9cfad3a3d84040d1

See more details on using hashes here.

Supported by

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