Skip to main content

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.

Metadata

Release files for lh 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lh 0.0.6
File Size Uploaded
lh-0.0.6.tar.gz 8.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lh 0.0.6
File Interpreter ABI Platform
lh-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 15.8 kB

Release files / lh-0.0.6.tar.gz

Download URL lh-0.0.6.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
88645be0699c80524d389bff6fd0e24601bd00974ce992b25370a7d1ecb17d98
BLAKE2b-256 checksum
How to use checksums
6c2106819f74fb68ef33267bf9a97d4e826e3dbcaf61c40afe1b1074384e2c44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / lh-0.0.6-py3-none-any.whl

Download URL lh-0.0.6-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f0cedb738f527ccdfc962d1c82a055f1bed0a828216bfe4421de89e5d432054
BLAKE2b-256 checksum
How to use checksums
08b42d6870b20ebeccd2fdeb5f71acb353ead3e769387bbd85d1b7440f3e5482
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page