Table of Contents
About
A custom logging module for Python that supports colorized output and log file rotation. Includes features such as configurable log levels, custom formatters, and automatic deletion of old log files.
Installation
The package is available on PyPI and can be installed via pip:
python -m pip install fxlog
How-to Use
You can use the fxlog module in your Python scripts as follows:
Save Log Files
If you want to save the log files 1, import the fxlog module, and set the log directory where log files will be stored:
from fxlog import fxlogger
fxlogger.set_log_directory('path/to/log/directory')
E.g.,
import os
from pathlib import Path
from fxlog import fxlogger
_PACKAGE_NAME = "package_name"
DATA_DIR = (
Path(os.getenv("APPDATA")) / _PACKAGE_NAME
if os.name == "nt"
else Path.home() / f".{_PACKAGE_NAME}"
)
LOG_DIR = DATA_DIR / "logs"
LOG_DIR.mkdir(parents=True, exist_ok=True)
fxlogger.set_log_directory(LOG_DIR)
Then, you can use the fxlog module to create a logger object and log messages to the console and a log file:
from fxlog import fxlogger
logger = fxlogger.configure_logger('my_logger')
logger.debug('This is a debug message')
To delete old log files, you can use the fxlog module as follows:
from fxlog import fxlogger
fxlogger.delete_old_logs(7) # Delete log files older than 7 days
You can also clear all log files in the log directory:
from fxlog import fxlogger
fxlogger.clear_logs()
Do Not Save Log Files
If you don't want to save the log files, you can use the fxlog module as follows:
from fxlog import fxlogger
logger = fxlogger.configure_logger('my_logger', save_to_file=False)
logger.debug('This is a debug message')
Set Log Level
You can set the log level of all loggers by using the set_loggers_level function:
from fxlog import fxlogger
fxlogger.set_loggers_level(fxlogger.DEBUG) # You can also use `logging.DEBUG`
Set Formatter
By default, the output looks like this:
You can enable a colored output by setting the enable_color parameter to True. The messages will be colorized according to their log levels:
from fxlog import fxlogger
logger = fxlogger.configure_logger('my_logger', enable_color=True)
logger.debug('This is a debug message')
You can also enable a separator between log messages by setting the enable_separator parameter to True:
from fxlog import fxlogger
logger = fxlogger.configure_logger('my_logger', enable_separator=True)
logger.debug('This is a debug message')
Contact
Project Link: fxlog
Metadata
Release files for fxlog 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fxlog-0.2.2.tar.gz | 1.7 MB | Without provenance | Details for fxlog-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fxlog-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for fxlog-0.2.2-py3-none-any.whl |
Total release size: 1.7 MB
Release files / fxlog-0.2.2.tar.gz
| Download URL | fxlog-0.2.2.tar.gz |
|---|---|
| Size | 1.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
08f774a1179a0b28f5e8f55c6e9ef13587fe0ddcd095f5c771a997f0c730d8fe
|
|
BLAKE2b-256 checksum How to use checksums |
11d440e5a889e97f68f0d9c2fb71b9c40ff3e09e15942780c187ab1f9c041f36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / fxlog-0.2.2-py3-none-any.whl
| Download URL | fxlog-0.2.2-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
989310ac8f320a3c2d94dfa893c1cc3ae3783bf07eef1c8d5b5eaa76abade8f0
|
|
BLAKE2b-256 checksum How to use checksums |
b45fedd73cfd25afa272b16e86f9b5638c70cb4a49c5483f64526ec843a82213
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for fxlog 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.