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.1.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.1-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: levellogger-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 5b39324bb347628649b8176c5421ef21822ce7d8023d09d0e0776e50b7c2a8c4
MD5 5c3336882ebe2728e269760579b116ff
BLAKE2b-256 db74a35facb465d9b14de9394467ba7e1c9bd48da1d2c971bf84d3fe1f5c8b2f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: levellogger-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 16.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 09c59351ec78e802cbb7ce346b19dfdcac7fad7feaf1b9502e40da3fa34048c3
MD5 c30bbfbfe49fb30e220bf48bf5ecb678
BLAKE2b-256 607bf9cb65c0d59cc37d6de95172d6147a809ac46166ae8acc48167113588c21

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