npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mazhu/logpilot

v1.1.0

Published

多源日志聚合 CLI 工具 - 实时跟踪、搜索、聚合、过滤和告警

Readme

log-agg

多源日志聚合 CLI 工具 - 从文件、Docker、K8s、journald 聚合日志,统一格式搜索。

安装

npm install -g @mazhu/log-agg

功能特性

  • 🔍 多源支持: 本地文件、Docker 容器、Kubernetes Pods、systemd journald
  • 📊 实时跟踪: 同时跟踪多个来源的日志
  • 🔎 全文搜索: 跨所有来源搜索日志内容
  • 🎨 彩色输出: 不同来源和日志级别使用不同颜色
  • 📤 导出功能: 支持 JSON 和 CSV 格式导出
  • 🚀 零依赖: 纯 Node.js 实现,无需外部依赖

使用方法

实时跟踪日志

# 跟踪 Docker 容器日志
log-agg tail docker:myapp

# 跟踪本地文件
log-agg tail file:/var/log/syslog

# 跟踪 Kubernetes Pod
log-agg tail k8s:my-pod-name

# 跟踪 systemd 服务
log-agg tail journald:nginx

搜索日志

# 搜索所有来源中的错误
log-agg search "ERROR" --source docker:myapp --source file:/var/log/syslog

# 限制结果数量
log-agg search "timeout" --source docker:myapp --limit 50

# 搜索特定时间范围
log-agg search "failed" --source journald:nginx --since "1 hour ago"

聚合多个来源

# 同时查看多个来源
log-agg aggregate --source docker:app1 --source docker:app2 --source k8s:pod-1

# 持续跟踪 (follow 模式)
log-agg aggregate --source docker:myapp --source file:/var/log/nginx/access.log --follow

按级别过滤

# 只显示错误级别日志
log-agg filter --level error --source docker:myapp

# 显示警告级别
log-agg filter --level warn --source k8s:my-pod

# 多个来源
log-agg filter --level info --source docker:app1 --source docker:app2 --limit 100

导出日志

# 导出为 JSON
log-agg export --format json --output logs.json --source docker:myapp

# 导出为 CSV
log-agg export --format csv --output logs.csv --source docker:myapp --source k8s:pod-1

# 导出所有来源
log-agg export --format json --source docker:myapp --source file:/var/log/syslog

列出可用日志源

log-agg list

自动检测并显示:

  • 运行中的 Docker 容器
  • Kubernetes Pods
  • systemd 服务
  • 常见日志文件

来源格式

| 类型 | 格式 | 示例 | |------|------|------| | 文件 | file:<path> | file:/var/log/app.log | | Docker | docker:<container> | docker:myapp | | Kubernetes | k8s:<pod> | k8s:nginx-pod-abc123 | | journald | journald:<service> | journald:nginx.service |

命令参考

log-agg <command> [options]

Commands:
  tail <source>        实时跟踪日志
  search <pattern>     全文搜索所有来源
  aggregate            同时查看多个来源的日志
  filter               按级别过滤日志
  export               导出日志
  list, ls             列出可用日志源
  help                 显示帮助信息
  version              显示版本

Options:
  --source <source>    指定日志来源 (可多次使用)
  --limit <n>          限制返回行数
  --since <time>       从指定时间开始
  --follow, -f         持续跟踪新日志
  --level <level>      过滤级别: error, warn, info, debug
  --format <format>    导出格式: json, csv
  --output <file>      导出文件路径

系统要求

  • Node.js >= 16.0.0
  • Docker (可选,用于 Docker 日志)
  • kubectl (可选,用于 Kubernetes 日志)
  • systemd (可选,用于 journald 日志)

开源协议

MIT License

作者

Mike Wang [email protected]


⭐ 如果这个项目对你有帮助,请给我们在 GitHub 上点个 Star!