/logger_generate

python 生成 logger 用的 清涼舒爽。 generate python logger

Primary LanguagePythonMIT LicenseMIT

logger_generate

Codacy Badge

生成 logger 用的,清涼舒爽
開箱即用的 logger。

A python package
easy to generate logger.

Install

PIP

pip install -U logger-generate

Poetry

poetry add logger-generate

PIP from Github

pip install git+https://github.com/we684123/logger_generate@main

Example

from config import base
from logger_generate import generate

logger = generate()
logger.info("引入即用 ( •̀ ω •́ )✧")

logger_config = {
    "logging_level": 'DEBUG',
    "log_file_path": './logs/by_logger_config.log',
    "log_format": '%(asctime)s - %(levelname)s : %(message)s',
    "backupCount": 7,
    "when": 'D',
    "encoding": 'utf-8',
}
logger = generate(logger_config, name='from_dict')
logger.info("亦可用程式內 dict 設定")

logger = generate(base.logger_config(), "from_config_file")
logger.info("也以用從檔案引入 config")

logger = generate(logger_config, name='方便生成隨機log名稱', need_serial=True)
logger.info("←後方隨機5字元")

logger = generate(base.logger_config(), "ex", True)
logger.info("示範單純用位置作為輸入手段")

logger = generate(logging_level='DEBUG',
                  name='use_kwargs',
                  log_file_path='./logs/use_kwargs.log')
logger.info("現在也可以用 kwargs 設定 logger")

2022-10-29 22_38_04-logger_generate @ z170_hero