A simple logger for Python.
Project description
shiertier_logger
English | 中文
Introduction
shiertier_logger is a Python logging utility designed to simplify logging with internationalization (i18n) support. It integrates seamlessly with the loguru library and provides a straightforward interface for logging messages in different languages. The library also supports automatic log file rotation and configuration via environment variables.
Installation
You can install shiertier_logger via pip:
pip install git+https://github.com/shiertier-utils/shiertier_logger.git
Please note that this project is still under development.
Usage
Initialization
The logger is automatically initialized when you import the module. The log files are stored in the directory specified by the LOG_DIR environment variable, or in the .shiertier/logs directory under the user's home directory if LOG_DIR is not set.
from shiertier_logger import logger
# or use Logger_I18n, need shiertier_i18n support
from shiertier_logger import easy_logger_i18n
Logging Messages
You can use the easy_logger_i18n object to log messages with translation support:
easy_logger_i18n.info("Hello, world!")
You can also pass a dictionary to replace placeholders in the logged message:
easy_logger_i18n.info("Hello, $$name$$!", replace_dict={'$$name$$': 'Alice'})
Available Methods
info(message: str, replace_dict: Dict[str, Any] = None) -> Nonedebug(message: str, replace_dict: Dict[str, Any] = None) -> Nonewarning(message: str, replace_dict: Dict[str, Any] = None) -> Noneerror(message: str, replace_dict: Dict[str, Any] = None) -> None
Configuration
Log Directory
By default, the log files are stored in the directory specified by the LOG_DIR environment variable. If LOG_DIR is not set, it defaults to the .shiertier/logs directory under the user's home directory.
You can set the LOG_DIR environment variable to specify a different directory:
export LOG_DIR=/path/to/logs
Log Level
The log level can be configured via the LOG_LEVEL environment variable. The default log level is INFO.
You can set the LOG_LEVEL environment variable to specify a different log level:
export LOG_LEVEL=DEBUG
Log to System Output
By default, the logger logs to both a file and the system output (stdout). You can disable logging to the system output by setting the LOG_SYS environment variable to False.
export LOG_SYS=False
Dependencies
logurushiertier_i18n(optional, for translation support)
License
This project is released under the MIT License. See the LICENSE file for details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shiertier_logger-0.0.5.tar.gz.
File metadata
- Download URL: shiertier_logger-0.0.5.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
036ace61441d6e81c3368e3f332c63c8f3dc3cf7c1271e9c09065a360c9d9ce4
|
|
| MD5 |
1a7cd24840ae75321a1e3a0a2305eacf
|
|
| BLAKE2b-256 |
24981dabbb36080ae7e95e6cad709026da2b7d5e03ed337177c36ed8904b97e3
|
File details
Details for the file shiertier_logger-0.0.5-py3-none-any.whl.
File metadata
- Download URL: shiertier_logger-0.0.5-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f22411fdc52db90df157c8e59cde58b5c9055e55ce112dfb37c93a45753b675
|
|
| MD5 |
b473d55c6b230e447ff674a558b18560
|
|
| BLAKE2b-256 |
15a52c74f8d6778bc5eb39e7ef7cf79c9f4fcf65b69b94cfdf5c9b8affd0c5c4
|