Skip to main content

No project description provided

Project description

Level Logger

Level Logger is a Python class that provides a simple and customizable logging system with colored output. It allows you to log messages at different levels of severity and customize the appearance of your log messages.

image

Features

  • Six logging levels: DEBUG, INFO, ATTENTION, WARNING, ERROR, and CRITICAL
  • Colored output for easy visual distinction between log levels
  • Customizable message header
  • Ability to enable/disable logging
  • Timestamp included with each log message

Installation

To use the Level Logger, run pip install levellogger

Usage

Here's a basic example of how to use the Logger:

  from levellogger import Logger

  # Initialize the logger
  logger = Logger(level="DEBUG", header="MyApp")
  
  # Log messages at different levels
  logger.debug("This is a debug message")
  logger.info("This is an info message")
  logger.attention("This is an attention message")
  logger.warning("This is a warning message")
  logger.error("This is an error message")
  logger.critical("This is a critical message")

API Reference

Constructor

  Logger(level: Union[int, str] = "INFO", header: str = None)
  • level: The initial log level. Can be a string ("DEBUG", "INFO", "ATTENTION", "WARNING", "ERROR", "CRITICAL") or an integer (0-5). Defaults to "INFO".
  • header: An optional message header to be included in all log messages.

Methods

  • set_message_header(header: str): Set the message header.
  • enable_logging(): Enable logging.
  • disable_logging(): Disable logging.
  • debug(message: str): Log a debug message.
  • info(message: str): Log an info message.
  • attention(message: str): Log an attention message.
  • warning(message: str): Log a warning message.
  • error(message: str): Log an error message.
  • critical(message: str): Log a critical message.
  • set_level(level: int): Set the log level.

Example

  logger = Logger()
  logger.set_level(logger.DEBUG)
  logger.set_message_header("Test Logger")
  logger.debug("This is a debug message")
  logger.info("This is an info message")
  logger.attention("This is an attention message")
  logger.warning("This is a warning message")
  logger.error("This is an error message")
  logger.critical("This is a critical message")

This will output colored log messages with timestamps and the specified header.

License

This project is open-source and available under the GNU 3 License.

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

levellogger-0.2.2.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

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

levellogger-0.2.2-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file levellogger-0.2.2.tar.gz.

File metadata

  • Download URL: levellogger-0.2.2.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.6

File hashes

Hashes for levellogger-0.2.2.tar.gz
Algorithm Hash digest
SHA256 17569f01c912e0ee6c1da3ea984f9a89ed039f39a06b9c28c59aa6d7b48db5a5
MD5 dec85990008a4b87b9f8d7d6f168a4a0
BLAKE2b-256 6e81937b627be29003c59b5d414cc92d0a2bbe970072451fa0661136f03d8185

See more details on using hashes here.

File details

Details for the file levellogger-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: levellogger-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.6

File hashes

Hashes for levellogger-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dbe46af6d71e850020c36a8554ebec739cec41f53fdc58fdf3ad49c42941eb8a
MD5 94e0411b2b69bc3efc52e02b471225b0
BLAKE2b-256 18e30eab1a311063f7c517c2b9b8595d71f2cfe10250d817f8588be7371ded0c

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