Patch your print function.
Project description
xprintlog
- 无侵入
- 帮助你替换将函数内部的print函数替换为logging
安装
pip install xprintlog
使用
- 直接使用装饰器进行装饰
# test.py
import xprintlog as xprint
@xprint.xprint()
def test():
print(111)
test()
#[.\test.py:6 - test][DEBUG] - 111
- 使用类似于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()
# 这里没有输出
- 支持函数嵌套,且函数间互不影响
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
Release history Release notifications | RSS feed
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)
Built Distribution
Close
Hashes for xprintlog-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0707cd2ccb443f9091f8db86bc8c32f560d0986261f7889386e97bc2ae5b46d |
|
MD5 | 3c05ca472bb6d21b9056a5ae2ccd7d4a |
|
BLAKE2b-256 | 9f6d0fa875e4eab0cd5fa2dc9a543a0781b9ecbf0e82811b314e627900dee834 |