Skip to main content

A custom logging package

Project description

Logged.py

A custom logging package with advanced features including color-coded console output, log rotation, and compression.

Installation

To install the package you can run this command in your command prompt or powershell.

pip install logged

Usage

Importing the Package

import logged

Creating a Logger

Create a Logger instance with the desired output type and format.

logger = logger.Logger(output_type='console', format='<bold><gray>/d</gray> <type>/t</type></bold>       /m', utc=None)

output_type: Specify "console" for console output or "file" for file output.

format: Define the log message format using custom tags (e.g., /d for date, /t for type, /m for message).

file: If you chose output type as "file" this is a required parameter which must include the log file path.

utc: Adds this parameter to the UTC date. If left empty it will use local time.

Logging Messages

You can use different methods to log messages at various levels:

logger.trace("This is a trace message.")
logger.debug("This is a debug message.")
logger.info("This is an info message.")
logger.warn("This is a warning message.")
logger.error("This is an error message.")
logger.fatal("This is a fatal message.")
logger.all("This is a message for all levels.")

Features

  • Customizable Formatting: Use ANSI color codes and custom tags in log messages.
  • Log Rotation with Compression: Automatically rotates log files and compresses old logs into ZIP archives.
  • Flexible Output Options: Choose between console and file output.

API Reference

Logger A class for logging messages.

Constructor:

output_type: "console" or "file". Default is "console". format: Log message format. Default is "/d /t /m". <str?>file: File path for file output.

Methods:

trace(message: str): Logs a trace message.

debug(message: str): Logs a debug message.

info(message: str): Logs an info message.

warn(message: str): Logs a warning message.

error(message: str): Logs an error message.

fatal(message: str): Logs a fatal message.

all(message: str): Logs a message for all levels.

Example:

import logger

# Initialize logger
logger = logger.Logger(output_type='file', format='<bold><gray>/d</gray> <type>/t</type></bold>       /m', file='logfile.txt')

# Log messages
logger.info("This is an info message.")
logger.error("This is an error message.")

License

This package is licensed under the MIT License. See the LICENSE file for details.

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

logged-0.3.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

logged-0.3.1-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file logged-0.3.1.tar.gz.

File metadata

  • Download URL: logged-0.3.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for logged-0.3.1.tar.gz
Algorithm Hash digest
SHA256 999913e5c47b123fba1fcb4d19dd55b9de3fd4a28bb9b0bfff0c1935c2016ed7
MD5 9c0ce56d95b3cd673b39a0313464c898
BLAKE2b-256 bfc8e0c3a95549b502df3d2f5982c366aa6895539ae415a42d03113a7be413aa

See more details on using hashes here.

File details

Details for the file logged-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: logged-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for logged-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92f12d710fb604d5a80040c930c9ce501bce6a4545159cc4dcf714332dbee767
MD5 9ad213c1d4a668194c4b5260b198d748
BLAKE2b-256 f01afb4a7579e06de558eef68eb37f0840509dbcd70f3a856abec548848f14d7

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