Skip to main content

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/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) -> None
  • debug(message: str, replace_dict: Dict[str, Any] = None) -> None
  • warning(message: str, replace_dict: Dict[str, Any] = None) -> None
  • error(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

  • loguru
  • shiertier_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

shiertier_logger-0.0.4.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shiertier_logger-0.0.4-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file shiertier_logger-0.0.4.tar.gz.

File metadata

  • Download URL: shiertier_logger-0.0.4.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

Hashes for shiertier_logger-0.0.4.tar.gz
Algorithm Hash digest
SHA256 6b2b71c23a7afc10070855175419c6c874108dd3f2c2e379e2d91f295521bc83
MD5 202dcabc6f64bd1312fb6cc8ee5dc03a
BLAKE2b-256 2b4f9b952d323836cf08da3d7755e79f053d2ff353f422e9e387ca5abaeb1665

See more details on using hashes here.

File details

Details for the file shiertier_logger-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for shiertier_logger-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ac16ffe2a0ebcdf621aae913a9098af2a40b9adfbc203e9e5da598cae1585947
MD5 95a094754649f296ff3dcbdabcbfa595
BLAKE2b-256 ef2dcbd0fea34db9cac34c08c5931c940e697feeaba0b87c4b81774c2536251a

See more details on using hashes here.

Supported by

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