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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file xprintlog-0.0.2.tar.gz.

File metadata

  • Download URL: xprintlog-0.0.2.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.3

File hashes

Hashes for xprintlog-0.0.2.tar.gz
Algorithm Hash digest
SHA256 0ccaf275a42d366a913a6c5c54b980f4b3e6e7de0ef82ff7e17b69e48085b783
MD5 9c25a6c32bf6dd9796a9c13446433b09
BLAKE2b-256 14be8f49c868d3ce048fd5cf42213cfd81fc7e63fc2811429f0d2923b9231493

See more details on using hashes here.

File details

Details for the file xprintlog-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: xprintlog-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.3

File hashes

Hashes for xprintlog-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d0707cd2ccb443f9091f8db86bc8c32f560d0986261f7889386e97bc2ae5b46d
MD5 3c05ca472bb6d21b9056a5ae2ccd7d4a
BLAKE2b-256 9f6d0fa875e4eab0cd5fa2dc9a543a0781b9ecbf0e82811b314e627900dee834

See more details on using hashes here.

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