Skip to main content

micropython-lagan

介绍

基于micropython语言的日志库.

lagan取名来自于宜家的水龙头"拉根"。

本软件包已上传到pypi,可输入命令直接安装。

pip install micropython-lagan

功能

  • 支持日志在终端实时打印
  • 支持二进制流打印
  • 支持带颜色的日志打印

与python标准版lagan相比,micropython版本的lagan删除了输出到日志文件的功能。

error打印函数名改为err,原因是使用error函数名在设备运行会报错。

示例

# 默认输出界别是info,本行不会打印
lagan.debug("case4", "debug test print")

lagan.info("case4", "info test print")
lagan.warn("case4", "warn test print")
lagan.err("case4", "error test print")

输出:

186172:12:16 -  I/case4: info test print
186172:12:16 -  W/case4: warn test print
186172:12:16 -  E/case4: error test print

注意:时间戳是基于设备本地时钟,不是标准时间。

二进制流打印

s = bytearray()
for i in range(100):
    s.append(i)
lagan.print_hex('case2', lagan.LEVEL_ERROR, s)

输出:

186172:11:40 -  E/case2: 
****00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
---- : -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
0000 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
0010 : 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
0020 : 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
0030 : 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
0040 : 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
0050 : 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
0060 : 60 61 62 63 

颜色控制

可以使用EnableColor函数开控制打开或者关闭日志颜色,默认关闭颜色。

lagan.set_filter_level(lagan.LEVEL_DEBUG)
lagan.enable_color(True)
lagan.println('case1', lagan.LEVEL_OFF, 'TestPrintOut1:%d', 100)
lagan.println('case1', lagan.LEVEL_DEBUG, 'TestPrintOut1:%d', 100)
lagan.println('case1', lagan.LEVEL_INFO, 'TestPrintOut1:%d', 100)
lagan.println('case1', lagan.LEVEL_WARN, 'TestPrintOut1:%d', 100)
lagan.println('case1', lagan.LEVEL_ERROR, 'TestPrintOut1:%d', 100)

s = bytearray()
for i in range(100):
    s.append(i)
lagan.print_hex('case2', lagan.LEVEL_INFO, s)

图片

Metadata

Release files for micropython-lagan 1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for micropython-lagan 1.4
File Size Uploaded Provenance
micropython-lagan-1.4.tar.gz 3.7 kB Without provenance Details

Release files / micropython-lagan-1.4.tar.gz

Download URL micropython-lagan-1.4.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8d9d7a63e4b8c750cea99ec4f4868615604cb53ce1f70224f8c6c4c186fe54d6
BLAKE2b-256 checksum
How to use checksums
a3b8b7c1ca35a7cddd85004de1818b9ceb46750f5eb0f0a5e1e1b4f96e7e8250
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.7

Security for micropython-lagan 1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page