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.2.tar.gz (3.2 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.2-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: shiertier_logger-0.0.2.tar.gz
  • Upload date:
  • Size: 3.2 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.2.tar.gz
Algorithm Hash digest
SHA256 02a032cbee0d46d23154202c6eef23aa5bed1f85776d85338478ca369dfc0d33
MD5 bfd11ce5fa970fd3fac231f5cccfc461
BLAKE2b-256 0ef25565621b1251ceb426b91779d4ba2f1f1f3d378aab9941ef251a16c1cc74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for shiertier_logger-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c7d6587c5af35c33240f2fed292bfab29261158b6452a718d46631b6de6cd6e7
MD5 a420ccc9d0cefb4a2b1a3a25e884a417
BLAKE2b-256 4edac6b578dc8716f69735ec2d0631ce4754df6bd997f844edc0662063e498dd

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