Skip to main content

[easylog](https://github.com/prprprus/easylog) 的 Python 客户端实现

Project description

easylogcli

简介

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

需要 Python 版本大于等于 3.6

安装

pip install easylogcli

使用例子

from easylogcli.easylog import EasyLog
import time


def test():
    # 创建客户端
    client = EasyLog()

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

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

    # 关闭客户端
    client.close()


if __name__ == '__main__':
    test()

配置文件 config.json 说明:

{
  "name": "log-server",   # 对应日志服务器配置文件中的 name 字段
  "host": "127.0.0.1",    # 日志服务器 IP
  "port": 10000,          # 日志服务器端口
  "absolute_path": "/Users/tiger/develop/tmp/1.txt"   # 日志存储路径
}

输出的日志格式例子:

[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
  • 批量发送
  • 发送失败时报警
  • ...

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

easylogcli-1.1.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

easylogcli-1.1.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file easylogcli-1.1.1.tar.gz.

File metadata

  • Download URL: easylogcli-1.1.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for easylogcli-1.1.1.tar.gz
Algorithm Hash digest
SHA256 805836bdcb7932da8511dea21cac839f6dfb33359e768d0c8a8401854df08f9b
MD5 af4812929304811c539c3967361503fb
BLAKE2b-256 639fc39d5f702516843fa99a92a01562152243596ec95e619b8e1703fa1a8d14

See more details on using hashes here.

Provenance

File details

Details for the file easylogcli-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: easylogcli-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for easylogcli-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b3f9a9060a3382f056d923808b675d1d8486694af58c1f0479519aebf711ed8e
MD5 51cb6b9de4b54f6acbf52ace2047d901
BLAKE2b-256 59e0b99078c08bdf75a1995f33a49f02e9a5b3d644017f25f3ecb95fbd246323

See more details on using hashes here.

Provenance

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