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.3.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.3-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: shiertier_logger-0.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 5ee1604d2dcfe3a064984f843c2b8ede476442d7982cb81cf1abffd3439abb37
MD5 565ee1f3d15273a9eb58ee27f0127765
BLAKE2b-256 5c5c12c628c91dbb9e8f29cd9795c47003e2b0ef4e42d5c3cb26f70c71d95222

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for shiertier_logger-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 006d9cf6d23ec0d6ccef112773eb8909548dec84f3c2757a855a30053a1fd514
MD5 979a221e86b9236774a5de23733f1715
BLAKE2b-256 01647a7110f47e09a5f1a70269f533436ade8ec8f0f0cd8e1eae89f533a2f46c

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