Skip to main content

Patch your print function.

Project description

xprintlog

  • 无侵入
  • 帮助你替换将函数内部的print函数替换为logging

安装

pip install xprintlog

使用

  1. 直接使用装饰器进行装饰
# test.py
import xprintlog as xprint
@xprint.xprint()
def test():
    print(111)

test()
#[.\test.py:6 - test][DEBUG] - 111
  1. 使用类似于logging的方式,进行等级设置
import xprintlog as xprint
@xprint.xprint(
    print_level=xprint.INFO,
    level=xprint.DEBUG
)
def test():
    print(111)


test()
# [.\test.py:7 - test][INFO] - 111

@xprint.xprint(
    print_level=xprint.DEBUG,
    level=xprint.INFO
)
def test1():
    print(111)


test1()
# 这里没有输出
  1. 支持函数嵌套,且函数间互不影响
import xprintlog as xprint
@xprint.xprint(
    print_level=xprint.INFO,
    level=xprint.DEBUG
)
def test():
    print(111)

@xprint.xprint(
    print_level=xprint.DEBUG,
    level=xprint.INFO
)
def test1():
    print(111)
    test()


test1()
# [.\test.py:7 - test][INFO] - 111

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

xprintlog-0.0.2.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

xprintlog-0.0.2-py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 3

Supported by

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