Skip to main content

LogWatch 客户端 - 包裹命令并上传日志到监控服务器

Project description

╔══════════════════════════════════════════════════════════════════════════╗
║                                                                          ║
║   ██╗      ██████╗  ██████╗ ██╗    ██╗ █████╗ ████████╗ ██████╗██╗  ██╗ ║
║   ██║     ██╔═══██╗██╔════╝ ██║    ██║██╔══██╗╚══██╔══╝██╔════╝██║  ██║ ║
║   ██║     ██║   ██║██║  ███╗██║ █╗ ██║███████║   ██║   ██║     ███████║ ║
║   ██║     ██║   ██║██║   ██║██║███╗██║██╔══██║   ██║   ██║     ██╔══██║ ║
║   ███████╗╚██████╔╝╚██████╔╝╚███╔███╔╝██║  ██║   ██║   ╚██████╗██║  ██║ ║
║   ╚══════╝ ╚═════╝  ╚═════╝  ╚══╝╚══╝ ╚═╝  ╚═╝   ╚═╝    ╚═════╝╚═╝  ╚═╝ ║
║                                                                          ║
╚══════════════════════════════════════════════════════════════════════════╝

⚡ 实时日志监控客户端 ⚡

PyPI Python License

┌─────────────────────────────────────────────────────────────┐
│  包裹任意命令 → 实时上传日志 → LogWatch 服务端              │
└─────────────────────────────────────────────────────────────┘

🚀 快速开始

📦 安装

# 推荐使用 uv(更快)
uv tool install logwatch-client

# 或使用 pip
pip install logwatch-client

⚙️ 初始化

# 交互式配置向导
lw --setup

# 健康检查
lw --health

🎯 运行任务

lw --user-id 104698 --user-token ut_xxx python long_running_test.py



🤖 AI 辅助安装与配置

让 AI 助手自动完成安装和配置流程

📋 准备工作

在开始之前,请准备以下信息:

  • 🌐 服务端地址 — 例如 http://127.0.0.1:8000
  • 🆔 用户 ID — 在网页中查看
  • 🔑 用户 Token — 在网页设置中创建
✨ 一键安装(推荐)

复制以下内容发给 AI 助手(Codex / Claude Code):

请帮我安装和配置 logwatch-client:
参考 AI 协作手册 (https://raw.githubusercontent.com/Becomingw/logwatch_client/refs/heads/main/docs/ai-assistant-playbook.md) 来完成
🛠️ 手动安装
# 安装客户端
uv tool install logwatch-client || pip install logwatch-client

# 运行配置向导
lw --setup

# 验证安装
lw --health



📝 配置文件

配置文件路径: ~/.lwconfig

最小可用配置

server=http://127.0.0.1:8000
machine=my-macbook
user_id=104698
user_token=ut_xxx

💡 鉴权说明: 客户端上报接口统一使用 user_id + user_token




💻 常用命令

# 配置向导
lw --setup

# 健康检查
lw --health

# 运行任务(带名称)
lw --name "train-exp-1" python train.py

# 指定服务器
lw --server http://127.0.0.1:8000 python train.py

# 跳过连通性检查
lw --no-check python train.py



📖 命令行参数

参数 简写 说明
--name -n 任务名称
--server -s 服务器地址
--machine -m 机器标识
--user-id -u 用户 ID
--user-token 用户 Token
--setup 交互式配置向导(含连通+上报测试)
--health 健康检查(连通性/队列/离线邮件)
--no-check 跳过启动前连通性检查
--init 已废弃,等价于 --setup



⚙️ 完整配置项

展开查看所有配置选项
# ═══════════════════════════════════════════════════════════
# 基础配置
# ═══════════════════════════════════════════════════════════
server=http://127.0.0.1:8000
machine=my-macbook
user_id=104698
user_token=ut_xxx

# ═══════════════════════════════════════════════════════════
# 上传配置
# ═══════════════════════════════════════════════════════════
upload_interval_seconds=2
batch_size=100
batch_interval_ms=5000
compression_level=6
publish_grace_seconds=1
upload_circuit_break_max=5

# ═══════════════════════════════════════════════════════════
# 日志管理
# ═══════════════════════════════════════════════════════════
log_retention_days=7
log_max_files=1000
force_offline=false

# ═══════════════════════════════════════════════════════════
# 邮件通知
# ═══════════════════════════════════════════════════════════
email_enabled=false
email_notify_on=all
email_notify_on_start=false
smtp_host=smtp.example.com
smtp_port=465
smtp_user=your-email@example.com
smtp_pass=your-password
smtp_use_tls=true
email_from=your-email@example.com
email_to=notify@example.com



🔧 运行机制

📁 本地存储

  • 日志目录 ~/.lw_logs
  • 队列数据库 ~/.lw_logs/queue.db (SQLite WAL)

📤 上传策略

  • 批量上传 每 100 条或 5 秒触发
  • 心跳上报 默认每 30 秒
  • 失败重试 指数退避

🔍 健康检查

  • 连通性探测 GET /api/health
  • 离线模式 达到阈值后自动进入


┌─────────────────────────────────────────────────────────────┐
│                                                             │
│  Made with ⚡ by LogWatch Team                              │
│  📚 Documentation • 🐛 Issues • 💬 Discussions              │
│                                                             │
└─────────────────────────────────────────────────────────────┘

© 2024 LogWatch • MIT License

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

logwatch_client-0.1.3b1.tar.gz (26.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logwatch_client-0.1.3b1-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file logwatch_client-0.1.3b1.tar.gz.

File metadata

  • Download URL: logwatch_client-0.1.3b1.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for logwatch_client-0.1.3b1.tar.gz
Algorithm Hash digest
SHA256 f4e8acc6208dd392024560f26be70b0ef84e8b15d84b0667a510139245103c60
MD5 270c1fc033d9a5395e699c31fe69cc23
BLAKE2b-256 47cca700ab0de46b93d35576e79e68360eca78dc135e35504c66173214d7a690

See more details on using hashes here.

File details

Details for the file logwatch_client-0.1.3b1-py3-none-any.whl.

File metadata

  • Download URL: logwatch_client-0.1.3b1-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for logwatch_client-0.1.3b1-py3-none-any.whl
Algorithm Hash digest
SHA256 c164eb775f7e967dbc53892f1cc8dc1fdb540c7216d1babd0dd05e096a983f40
MD5 c6b0f44c646e291bb4904b1588251e0c
BLAKE2b-256 95be6606705a489b4242182ec65dccd7eea8bd777d63eb9efa47652e55e4d7a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page