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.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for hlogger-1.3.0.tar.gz
Algorithm Hash digest
SHA256 3eee69295af095559dbf4fc54d1f18574f3fcee2fd085c1ae17d602823753b77
MD5 075108033df081e59d45c6ad8c69eec5
BLAKE2b-256 f529a86915b32ad4a459dd0e106b4f9eb6f9f768b68411376a568b6ca99fa3b1

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for hlogger-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d90e90fdfab533552fcd2d9284885c0ebb727c051c5230f011f47f81d8ddef8b
MD5 a055ba1a92c2f8df508bc10b25bc7614
BLAKE2b-256 f5c77e06c3b5a87d90bcfbef08d4e83de517e42d140f9d2e519994a0098961a3

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