The simplest Python logger for everyday tasks.
Project description
loggerpy
The simplest Python logger for everyday tasks.
Table of Contents
Installation
The easiest way to install is throw pip.
pip install loggerpy
Instructions
In order to use this simple logger, many examples are provided inside examples directory
Configuration
The main classes of the loggerpy
package are Logger
and Level
.
from loggerpy import Logger, Level
The Logger
class is a Singleton, so you can recall the __init__
method through Logger()
and the same instance will always be returned.
logger = Logger()
The possible customization of the logger instance are:
- name: the name of all loggers
- folder: the path of saving log if you want to save them
- print_level: the minimum level of printing
- save_level: the minimum level of saving, they can be different
In order to simplify the customization of printing and saving level it is provided a class that contained the 6 possible levels of logging. Importing Level from loggerpy, they can be used eg Level.DEBUG or Level.WARNING
- Level.NO_LOGGER
- Level.DEBUG
- Level.INFO
- Level.WARNING
- Level.ERROR
- Level.CRITICAL
The path can be set as absolute or relative. If the path is an absolute path it is used directly, otherwise it put after the project path. The default value is the project path
E.g.
Relative path
-------------
>>> logger.folder = 'relative_path'
In this case the used path is:
> /path/to/the/project/relative_path
Absolute path
-------------
>>> logger.folder = 'absolute_path'
It is setted as global path
> /absolute_path/
Configuration example
Logger
Now, it's time to create your first logger.
from loggerpy import Logger
logger = Logger()
logger.name = "First logger"
First logger example
Customization
The parameters of the Logger class can be set all in one time.
logger.configure(name="Name", log_folder="path/to/log/folder", print_level=Level.DEBUG, save_level=LEVEL.WARNING)
An example
Versions
stable version
-
1.0 :
- first release
-
1.1 :
- rewritten the input path of saving log in configure() and get_logger()
- configuration works properly for all file of your project
-
2.0 :
- Logger is now a Singleton
- Level is an enum
NextFeatures
- custom format for timestamp
- custom format for all log
- custom color for each level
License
This project is under the GPL-3.0 license - see the LICENSE.md file for more details
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
Built Distribution
File details
Details for the file loggerpy-2.1.1.tar.gz
.
File metadata
- Download URL: loggerpy-2.1.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e149accfb5fd044997f036a7239ee958a24e4a19497824863a4bbbea47ff7a95 |
|
MD5 | e4afc1e76a92222ff04d4503c13e97b3 |
|
BLAKE2b-256 | 429c65c89d98ec30f432c8dd2638a509b2510f945f6d0873b43f8ea7bf04cd70 |
File details
Details for the file loggerpy-2.1.1-py3-none-any.whl
.
File metadata
- Download URL: loggerpy-2.1.1-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b68472dc1d297ea705ee4d1a2768fbd1574a4c2ede16037e7cd0c4c7406de382 |
|
MD5 | df8901dd2d0b4f7facc9f598c623fd70 |
|
BLAKE2b-256 | 4256a396d51779f9137d4d2615915c3b32a7db2efdf08ce5ac01037e05034a6e |