A logger utility for python application
Project description
HLogger
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)
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1b4de9d8d075649c679223f71445ae80ba4eea1c135bde736b840f51015f67e |
|
MD5 | 810870899cce35cfed4080e4c276acfa |
|
BLAKE2b-256 | aa4e97b7c1f233ca48747d968e22d26067a03788d8fbf04212059b86de8fc26a |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72d3dbf9b273f88f42c1b7acd8205861aabab45bb7fc06085dcef5ad7aaea6e0 |
|
MD5 | 2a52b482f4a754127fef3ec5ceacc68b |
|
BLAKE2b-256 | 7d4ca0e9fbf1855bfae97f71aabf1ce8654e4b5fd90237d4cba0abb56d7756f8 |