Skip to main content

easylogcli

简介

easylogcli 是 easylog 的 Python 客户端实现,用于向服务端发送日志信息,无第三方依赖。

需要 Python 版本大于等于 3.6

安装

pip install easylogcli

使用例子

from easylogcli.easylog import EasyLog
import time


def test():
    # 创建客户端
    client = EasyLog(name='log-server', host='127.0.0.1', port=10000, absolute_path='/Users/tiger/develop/tmp/1.txt')

    # 发送日志
    client.send(message='下载图片成功')

    # 模拟持续运行
    time.sleep(0.1)

    # 关闭客户端
    client.close()


if __name__ == '__main__':
    test()

输出的日志格式例子:

[Tiger-3.local 172.16.4.251] INFO - 2020-03-06 14:41:54.517499 - (easylog.py:97) - 下载图片成功
[Tiger-3.local 172.16.4.251] INFO - 2020-03-06 14:41:54.517622 - (easylog.py:97) - 下载图片成功
[Tiger-3.local 172.16.4.251] INFO - 2020-03-06 14:41:54.517733 - (easylog.py:97) - 下载图片成功
[Tiger-3.local 172.16.4.251] INFO - 2020-03-06 14:41:54.517814 - (easylog.py:97) - 下载图片成功
[Tiger-3.local 172.16.4.251] INFO - 2020-03-06 14:41:54.520207 - (easylog.py:97) - 下载图片成功
[Tiger-3.local 172.16.4.251] INFO - 2020-03-06 14:41:54.520277 - (easylog.py:97) - 下载图片成功

日志格式解析:[主机名 IP] INFO - 日期时间 - (文件名:行数) - 日志内容

一些细节

客户端和服务端之间自定义了一个简单的消息体。

消息体例子:

absolute_path:/Users/tiger/develop/tmp/1.txt
content:[Tiger-3.local 172.16.4.251] INFO - 2020-03-06 11:38:32.616777 - (easylog.py:97) - 下载图片成功
----------

消息体字段解析:

  • absolute_path: 日志保存路径
  • content: 日志内容
  • ----------: 分隔符

TODO

  • CI
  • logging 代替 print
  • 批量发送
  • 发送失败时报警
  • 失败重试
  • ...

Metadata

Release files for easylogcli 1.2.9

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

Source distribution (sdist)

Source distribution for easylogcli 1.2.9
File Size Uploaded
easylogcli-1.2.9.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for easylogcli 1.2.9
File Interpreter ABI Platform
easylogcli-1.2.9-py3-none-any.whl Python 3 none any Details

Total release size: 8.1 kB

Release files / easylogcli-1.2.9.tar.gz

Download URL easylogcli-1.2.9.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7bcf5e2868aa73d990ae78f2cb3eb85a3a16003e0545294aa042b1e574f729bd
BLAKE2b-256 checksum
How to use checksums
caa681a99d72b0555620584f660bd12eda9ba1d4a0c9c1007f3a4b71d9cde1eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

Release files / easylogcli-1.2.9-py3-none-any.whl

Download URL easylogcli-1.2.9-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9eb50c1fed67e983c54ef3d843bc6fbd59fd5eb8b2566ce7481e86c4b4b36dc6
BLAKE2b-256 checksum
How to use checksums
e0d006c12a87493860f0c4c9aafccf116217023c46fa0b30784032a2a4a88b91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

Release history Release notifications | RSS feed

This release

1.2.9 This release

2 release files

1.2.8

2 release files

1.2.7

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.9

2 release files

1.1.8

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

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