Skip to main content

logging functions

Project description

lh

logging functions

To install: pip install lh

Overview

The lh package provides a set of utilities for logging and progress tracking in Python applications. It includes functions to print progress messages with timestamps, manage logging configurations, and output iterable items one per line.

Features

  • Progress Printing: Functions to display progress messages with the current time.
  • Logging Setup: Simplified setup for logging with custom configurations.
  • Iterable Printing: Utility to print each item of an iterable on a new line.

Usage

Progress Printing

print_progress

Prints a progress message with an optional timestamp.

from lh import print_progress

print_progress("Processing data...", refresh=True)

printProgress

Prints a formatted progress message with an optional timestamp, supporting sprintf-style string formatting.

from lh import printProgress

printProgress("Step {0} of {1}", args=[1, 10], refresh=True)

Logging Setup

get_a_logger

Creates and returns a logger with a specified configuration. Defaults to DEBUG level and outputs to 'default_log.log'.

from lh import get_a_logger

logger = get_a_logger(filename='app.log', level='INFO')
logger.info("Application started")

Iterable Printing

print_iter_one_per_line

Prints each element of an iterable on a new line.

from lh import print_iter_one_per_line

print_iter_one_per_line(['apple', 'banana', 'cherry'])

Function Documentation

hms_message

Generates a timestamped message.

  • Parameters:
    • msg (str): The message to timestamp.
  • Returns:
    • str: A string with the current day and time followed by the message.

print_progress

Prints a progress message, optionally refreshing the line and displaying the current time.

  • Parameters:
    • msg (str): The message to print.
    • refresh (bool, optional): Whether to refresh the line. Defaults to None.
    • display_time (bool, optional): Whether to display the current time. Defaults to True.

printProgress

Formatted version of print_progress supporting variable arguments.

  • Parameters:
    • message (str): The message template.
    • args (list, optional): List of arguments to format the message.
    • refresh (bool, optional): Whether to refresh the line.
    • refresh_suffix (str, optional): Suffix to append after the message when refreshing.

print_iter_one_per_line

Prints each item of an iterable on a new line.

  • Parameters:
    • it (iterable): The iterable whose items are to be printed.

get_a_logger

Sets up and returns a logger with specified configurations.

  • Parameters:
    • **kwargs: Arbitrary keyword arguments for logger configuration.
  • Returns:
    • logging.Logger: Configured logger object.

This package streamlines logging and progress tracking in Python, making it easier to manage output and diagnostics in your applications.

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

lh-0.0.5.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

lh-0.0.5-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file lh-0.0.5.tar.gz.

File metadata

  • Download URL: lh-0.0.5.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for lh-0.0.5.tar.gz
Algorithm Hash digest
SHA256 72c0ced8de44588a73e2bb9da34bdaafd1f8f7e711718334cfbb97d1f2724c10
MD5 e01e1adf1d759cdaae55dbc089285226
BLAKE2b-256 9bbcc5d2cf660b9c6965936ebea16961f3ef170d0db2bacc59b0367e1d6cf6c2

See more details on using hashes here.

File details

Details for the file lh-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: lh-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for lh-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 07e8449c9bbd9a436f18fd93562ffed1eee0dd2d8af4813a62d431b13bfe1f02
MD5 10ae2085984883758c0c55fd0a2668a5
BLAKE2b-256 ac2e900baadc42c6610bfffd41e7763c30380670e7183d46f79766836eb2e6a2

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