A simple python logger
Project description
spyl
a simple python logger
how to use
- download the logger and add to your project
pip install spyl
-
personalizing the logger
- when instantiating the
Loggerclass you can configure a few parameters about the logger logLevel, default toTrue- will the logger print out the level label e.g. if set to true:[12:00:00] [LEVEL] messageif set to false[12:00:00] messagecolorLevelText, default toTrue- will the level label get coloredquitWhenLogFatal, default toFalse- will the program quit when something with the fatal level is loggedcolorText, default toTrue- will the message get coloredprefixBeforeTime, default toTrue, - if a prefix is set will it be displayed before the timestampprefix [12:00:00] [LEVEL] messageor after[12:00:00] prefix [LEVEL] messagewarnLevel, an instance ofLogLevel, default toLogLevel("WARN", Fore.YELLOW)infoLevel, an instance ofLogLevel, default toLogLevel("INFO", Fore.RESET)debugLevel, an instance ofLogLevel, default toLogLevel("DEBUG", Fore.WHITE)errorLevel, an instance ofLogLevel, default toLogLevel("ERROR", Fore.LIGHTRED_EX),fatalLevel, an instance ofLogLevel, default toLogLevel("FATAL", Fore.RED, isFatal=True)prefix, default to""- the prefix of the entry that is to be logged (see theprefixBeforeTimeparameter)-
logging default levels
- import the library using
import spyl - create an instance of the
Loggerclasslogger = spyl.Logger()
-
to log a warning use the
logger.log_warningfunction -
to log an info message use the
logger.log_infofunction -
to log a debug message use the
logger.log_debugfunction -
to log an error use the
logger.log_errorfunction -
to log a fatal error use the
logger.log_fatalfunction -
adding additional custom levels
- import the library using
import spyl - import the colorama library using
from colorama import Fore - create an instance of the
Loggerclasslogger = spyl.Logger() - create an instance of the
LogLevelclasscustomLevel = spyl.LogLevel("CUSTOM", Fore.GREEN, isFatal=False)
- the
LogLevelclass has a few parameters which can be configured name- the name/label of the levelcolor- the color in which the level will be loggedisFatal, default toFalse- is the level fatal (this in important because if it is andlogger.quitWhenLogFatalis set to true and the level is fatal the program will exit when logged)
- log the custom level using
logger.log("message", customLevel)orcustomLevel.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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
spyl-1.0.1-py3-none-any.whl
(3.8 kB
view details)
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f4cb7879c62fcbd54c146729fd2193708301254e232ac68e44707c663e52e30
|
|
| MD5 |
0886c7e626aebe63ecbd3f8caa5b1f0f
|
|
| BLAKE2b-256 |
40db91b2f551f897d050709d35b589242bc4f21a0c92af1c7bef08740e3b214f
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b26506633420f110a95dc25eaa5e3e84c0ba9ffa165b177724a7efa52fecc637
|
|
| MD5 |
5b3de99f3dff90cb84930114dcb541f8
|
|
| BLAKE2b-256 |
7fe66059e01df2008f83e7da0b108ace77ebfe453d6285df9cfad3a3d84040d1
|