Skip to main content

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. Additionally, the new Home class offers customizable ASCII art displays for greeting users with special messages, branding, or system information.

🔥 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.
  • ASCII art display for personalized greetings, system info, and branding.
  • Simple and flexible API with multiple ways to use the Loader class.
  • Customizable text alignment for the Home ASCII art display.

⚙️ 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, Home

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")

# Customizable message
log.message("Dad", f"How are you? I'm gonna come soon!", start="", end="") # Start and end optional

# 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()

ASCII Art and Greeting (New Home Class)

The Home class lets you display customized ASCII art text along with system information, such as a welcome message, username, or credits.

Using the Home Class:

home_screen = Home(
    text="LogMagix",
    align="center",
    adinfo1="discord.cyberious.xyz",
    adinfo2="v1.0",
    credits="Developed by sexfrance",
    clear = False, # To clear the console, default is True
)

home_screen.display()

This will display the ASCII art version of "LogMagix" in the center of the terminal, along with optional adinfo1 and adinfo2 texts at the bottom. The terminal width is automatically detected to align the text properly.

Full Example

Here’s an example showing both logging, loader, and the new Home class functionality:

from logmagix import Logger, Loader, Home
import time
import uuid

log = Logger(prefix="custom/log/prefix")
start_time = time.time()

# Log messages
log.success("Everything is running smoothly!")
log.warning("Watch out, something might happen!")
log.failure("Critical error occurred!")
log.info("System is working properly")
log.debug(f"The system uuid is {uuid.getnode()}")
log.message("Dad", f"How are you? I'm gonna come soon!", start=start_time, end=time.time())
log.question("How old are you? ")


# Use loader with custom prefix and context manager
with Loader(prefix="custom/loader/prefix", desc="Processing data..."):
    time.sleep(2)  # 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(2)  # Simulate task
loader.stop()


home_screen = Home(
    text="LogMagix",
    align="center",
    adinfo1="discord.cyberious.xyz",
    adinfo2="v1.0",
    credits="Developed by sexfrance"
)

home_screen.display()


log.success("Processing completed!")

Customization in Home Class

  • text: The text to be displayed in ASCII art.
  • align: Align the ASCII art text to "left", "center", or "right" in the terminal.
  • adinfo1 and adinfo2: Additional information displayed below the ASCII art.
  • credits: Optional credits or user information.

❗ Requirements

LogMagix requires:

  • colorama for cross-platform color support in the terminal.
  • pystyle for creating the colored text effects.

To install dependencies, run:

pip install colorama pystyle

©️ 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.

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

logmagix-1.10.3.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

logmagix-1.10.3.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file logmagix-1.10.3.1.tar.gz.

File metadata

  • Download URL: logmagix-1.10.3.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for logmagix-1.10.3.1.tar.gz
Algorithm Hash digest
SHA256 b4fb863fa84dafe0e0aa04176844fe8b0543544d536ecb33073ee26fb585e08d
MD5 95fe5743c95649be6fce3254e7cee7f8
BLAKE2b-256 808b9f4998241d2337209e079148ff7292d54b77da8772b0991552b2b2526828

See more details on using hashes here.

File details

Details for the file logmagix-1.10.3.1-py3-none-any.whl.

File metadata

  • Download URL: logmagix-1.10.3.1-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for logmagix-1.10.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 453da05a0652b7f8fb770126637be14b1154c934700a03bf4e5a38d483db7f9e
MD5 e1d0bf9e56c71bca7ada145e1a19e70f
BLAKE2b-256 b3ba90b23ee89dafc8b52aaecba455261d8d144543befc629631d3c9167725e4

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