A custom logger package
Project description
LogMagix
LogMagix is a custom Python logging package that offers styled, colorful log messages for various logging levels such as success, warning, failure, and more. It also features an animated loader class for providing a visual indicator during long-running operations in the terminal.
🔥 Features
- Log messages for success, warning, failure, and informational levels.
- Customize message colors using ANSI escape sequences.
- Time-stamped log messages for better tracking.
- Built-in animated loader for visually appealing loading spinners.
- Customizable log and loader prefixes.
- Simple and flexible API with multiple ways to use the
Loaderclass.
⚙️ Installation
To install the package locally, clone the repository and run:
pip install .
You can also install it via pip from PyPI:
pip install logmagix
🔧 Usage
Importing the Package
from logmagix import Logger, Loader
Logging
Initialize the Logger class to log messages with different levels:
log = Logger()
# Success message
log.success("Operation completed successfully!")
# Failure message
log.failure("Something went wrong!")
# Warning message
log.warning("This is a warning!")
# Informational message
log.info("Informational log message")
# Debug message
log.debug("Debugging log message")
# Question input
log.question("This is an input question!")
Loading Animation
The Loader class can be used in two ways:
Using a context manager:
from time import sleep
with Loader(desc="Loading with context manager..."):
for i in range(10):
sleep(0.25)
Using start() and stop() methods:
loader = Loader(desc="Loading with object...", end="That was fast!", timeout=0.05).start()
for i in range(10):
sleep(0.25)
loader.stop()
Custom Log and Loader Prefix
Both the Logger and Loader classes allow for customizing the prefix that is shown before each message:
Logger Prefix:
log = Logger(prefix=".myapp/logs")
log.success("This message has a custom log prefix!")
Loader Prefix:
loader = Loader(prefix=".myapp/loader", desc="Loading with a custom loader prefix...")
loader.start()
time.sleep(5) # Simulate a task
loader.stop()
Full Example
Here’s an example showing both logging and loader functionality:
from logmagix import Logger, Loader
import time
log = Logger(prefix="custom/log/prefix")
# Log messages
log.success("Everything is running smoothly!")
log.warning("Watch out, something might happen!")
log.failure("Critical error occurred!")
# Use loader with custom prefix and context manager
with Loader(prefix="custom/loader/prefix", desc="Processing data..."):
time.sleep(5) # Simulate task
# Use loader with custom prefix and start/stop methods
loader = Loader(prefix="custom/loader/prefix", desc="Saving files...", end="Done!", timeout=0.05).start()
time.sleep(5) # Simulate task
loader.stop()
log.success("Processing completed!")
❗ Requirements
LogMagix requires:
coloramafor cross-platform color support in the terminal.
To install colorama, run:
pip install colorama
©️ License
LogMagix is licensed under the MIT License. See the LICENSE file for more details.
🖥️ Contributing
Contributions are welcome! Feel free to fork the repository, make changes, and submit a pull request.
👤 Author
LogMagix is developed and maintained by sexfrance.
Enjoy bringing more color and animation to your Python logging with LogMagix!
Project details
Release history Release notifications | RSS feed
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
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
File details
Details for the file logmagix-0.2.10.tar.gz.
File metadata
- Download URL: logmagix-0.2.10.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0320be15b561971bc3e718a06a8297ca551ae6ea0c9b0d14e78bd216dd2f1988
|
|
| MD5 |
f371638acfee413b2e0d40136c72fa91
|
|
| BLAKE2b-256 |
1b0ea8e64bfa8ba824b9aef0077018ca6fa5a32455159461c38884504d37a84c
|
File details
Details for the file logmagix-0.2.10-py3-none-any.whl.
File metadata
- Download URL: logmagix-0.2.10-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6c43442457cd2b521ec0a5398ca0711270782804ad336839fd92dad481ed94a
|
|
| MD5 |
bb5378e3590e9e53ec7e2ef6e85f38f7
|
|
| BLAKE2b-256 |
4c89d455d4b96b170f5751a67c0bf82b46f6c05a0539ed4609c463cb36471136
|