Skip to main content

Easy log

Project description

[TOC]

介绍

呆log:工业中,python日志模块,安装即用。理论上支持 python2, python3

为什么需要这个模块:

1. 规范化日志,且开箱即用
2. 解决了多进程丢失日志问题
3. 支持单例模式
4. 可能,真的很优雅
5. 很简单创建新的日志文件类型
6. 未来会变成python日志最佳实践
注意:作者仅提供使用,作生产使用前,请自行测试。出了问题,不要说自己当时大意,年轻人,要讲码德,望好自为之。
目前在 centos7.5 环境,mac环境,python3.6, 3.7 测试过。

好的功能

1. 规范化日志(可能是最佳日志实践)

安装方法

pip install dlog

参数介绍

呆log 参数与 使用方法

from dlog import DLog

if __name__ == '__main__':
     # ----------- 设定日志目录绝对路径(强烈建议) -----------
    import os

    RootPath = os.path.dirname(os.path.realpath(__file__))
    log_dir_path = os.path.join(RootPath, 'logs')

    log = DLog(log_dir_path=log_dir_path).get_log
    log.info('nice')
    log.warning('nice')
    log.error('nice')

    # ----------- 添加新的日志类型 -----------
    new_log_file_list = [{"file_name": "access", "log_level": "info"}, ]
    log1 = DLog(new_log_file_list=new_log_file_list).get_log   # 这个方式,日志目录在 现在这个文件平级目录下。
    log1.access('access my lord')

    # ----------- 开启单例模式 -----------
    log2 = DLog(singleton=True).get_log

    log2.info('nice')
    log2.warning('nice')
    log2.error('nice')

    # ----------- 一般方式 -----------
    log3 = DLog().get_log   # 这个方式,日志目录在 现在这个文件平级目录下。

    log3.info('nice')
    log3.warning('nice')
    log3.error('nice')

版本说明

1.0.2 支持 用户新添加 新日志文件,详见文档 《添加新的日志类型》。    caturbhuja
1.0.1 第一个版本,能用,但是没有达到最佳实践。    caturbhuja

后期版本规划

整理出日志最佳实践,完成一个开箱能用的工具

todo

感谢

dlog本身,集合了很多不知名的前辈的杰作,我的贡献和他们比起来,微乎其微。 非常感谢各位前辈的贡献。也希望未来的使用者能一起让这个库更好用。

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

dlog-1.0.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

dlog-1.0.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file dlog-1.0.2.tar.gz.

File metadata

  • Download URL: dlog-1.0.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.7

File hashes

Hashes for dlog-1.0.2.tar.gz
Algorithm Hash digest
SHA256 761428698aa31ba933915eaaab2d663d39c3f93243c2b6f24caac3c6f53f2330
MD5 2c1bfe43c01a253c220d4424f3ac08ee
BLAKE2b-256 5df1e487e5d6374969d091196f5a06202eddd41b2501fead55ee21092a500fdc

See more details on using hashes here.

File details

Details for the file dlog-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: dlog-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.7

File hashes

Hashes for dlog-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 653d6a197cb70cad47c329988b120ee350c4569abb397d6aeaca994836a53de3
MD5 68fe71664fdd6f13414f2374e281c174
BLAKE2b-256 f2485e47747c56bc2d7d8acb6fc9268c53210cd98f708e9528753fdfe06962e1

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