Skip to main content

A logger utility for python application

Project description

HLogger

PyPI - Version GitHub Actions Workflow Status Codecov

HLogger is a utility module that provides a flexible logging solution for Python applications. It allows you to easily create and manage loggers with both file and stream handlers.

Installation

You can install HLogger using pip:

$ pip install hlogger

Usage

Create Logger

from hlogger import create_logger

# Create a logger
logger = create_logger("app_logger", "app_log.log")

# Log messages
logger.info("Application started")

Create Logger with Specified Level

import logging
from hlogger import create_logger

# Create a logger
logger = create_logger("app_logger", "app_log.log", level=logging.WARNING)

# Log messages
logger.warning("WARNING: No module named 'missing_module'")

Get Logger

from hlogger import create_logger, get_logger

# Create a logger
logger = create_logger("app_logger", "app_log.log")

# Create another logger
logger = create_logger("app_logger2", "app_log2.log")

# Set logger to the previous one and log messages to it
logger = get_logger("app_logger")
logger.error("Application error")

Change Log File

from hlogger import create_logger

# Create a logger
logger = create_logger("app_logger", "app_log.log")

# Log messages
logger.info("Application started")

# Change the log file dynamically
logger = create_logger("app_logger", "new_app_log.log")

# Log messages to the new log file
logger.warning("Application warning")

Change Formatter

import logging
from hlogger import create_logger, set_formatter

# Create a logger
logger = create_logger("app_logger", "app_log.log")

# Change formatter
set_formatter("app_logger", logging.Formatter("%(message)s"))

# Log messages
logger.info("Application started")

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

hlogger-1.3.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

hlogger-1.3.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file hlogger-1.3.1.tar.gz.

File metadata

  • Download URL: hlogger-1.3.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for hlogger-1.3.1.tar.gz
Algorithm Hash digest
SHA256 f1b4de9d8d075649c679223f71445ae80ba4eea1c135bde736b840f51015f67e
MD5 810870899cce35cfed4080e4c276acfa
BLAKE2b-256 aa4e97b7c1f233ca48747d968e22d26067a03788d8fbf04212059b86de8fc26a

See more details on using hashes here.

File details

Details for the file hlogger-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: hlogger-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for hlogger-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 72d3dbf9b273f88f42c1b7acd8205861aabab45bb7fc06085dcef5ad7aaea6e0
MD5 2a52b482f4a754127fef3ec5ceacc68b
BLAKE2b-256 7d4ca0e9fbf1855bfae97f71aabf1ce8654e4b5fd90237d4cba0abb56d7756f8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page