@reneturcios/loglens

中文文档
0.1.0发布于 2026/11/02MITES Module

Homelab log investigation over a local JSONL log file: status, tail, errors, substring search, hourly or daily timelines, and surrounding context. One bin serves a small CLI and a stdio MCP server exposing a single action-dispatched tool.

原始使用文档
文档目录7 节
  1. Log file
  2. Install
  3. CLI
  4. MCP server
  5. Tool
  6. Development
  7. License

loglens

loglens investigates homelab logs held in a local file: what the store holds, what arrived most recently, what errored, what mentions a term, how volume is spread over time, and what surrounded a moment. One binary serves a command-line interface and a stdio MCP server exposing a single action-dispatched tool, cortex.

This is a labelled core subset. The tool it is modelled on dispatches 60 catalog actions; loglens implements seven of them — status, tail, errors, search, timeline, context, and help — and omits the other 53 (fleet and topology views, AI session analysis, correlation and anomaly analysis, error acknowledgement, notifications, and administration). The help action lists the implemented subset and the omitted actions at runtime.

Log file

Records live in a JSONL file: one JSON object per line, each with ts (an ISO-8601 timestamp), level, source, and message:

{"ts":"2026-10-26T09:15:00.000Z","level":"info","source":"docker/web","message":"container started"}
{"ts":"2026-10-26T09:16:12.000Z","level":"error","source":"syslog","message":"disk almost full"}

The path comes from --file on the CLI, then the LOGLENS_LOG_FILE environment variable, then ./loglens.jsonl. Malformed lines (bad JSON, missing fields, unparseable timestamps) are skipped and counted, never fatal. A missing file is a clean error for data actions; status instead reports the store state with exists: false, and help needs no store at all. All logic is local and deterministic — no network access, ever.

Install

npx @reneturcios/loglens status

Or run the container image:

docker run -i ghcr.io/cloudcorprecords/loglens

The container defaults to the MCP server (see below). Pass CLI arguments to use it as a CLI instead. Mount your log file and set LOGLENS_LOG_FILE to its in-container path.

CLI

export LOGLENS_LOG_FILE=/var/log/homelab.jsonl

loglens status
loglens tail --limit 5 --source docker/web
loglens errors --limit 10
loglens search "disk" --since 2026-10-26T00:00:00.000Z
loglens timeline --bucket day
loglens context 2026-10-26T09:16:12.000Z --window-minutes 5
loglens context 12 --limit 3
loglens help

loglens --version

Commands print a JSON result. tail, errors, and search return records newest first; context returns them in file order. context accepts either a timestamp (records within --window-minutes of it, or the --limit nearest records around the closest one) or a bare record index (the --limit records on either side of that position). Exit codes: 0 on success, 1 when an operation fails (including a missing log file), 2 for usage errors.

MCP server

One bin serves both faces. The mcp subcommand starts a stdio MCP server:

npx -y @reneturcios/loglens mcp

MCP client configuration:

{
  "mcpServers": {
    "loglens": {
      "command": "npx",
      "args": ["-y", "@reneturcios/loglens", "mcp"],
      "env": { "LOGLENS_LOG_FILE": "/absolute/path/to/logs.jsonl" }
    }
  }
}

Tool

ToolInputWhat it returns
cortexaction (required, one of status, tail, errors, search, timeline, context, help), plus optional query, source, level, limit, since, until, bucket (hour or day), timestamp, window_minutesPer action: a store summary, the latest matching records, hourly/daily volume buckets, records around a moment, or the subset help text.

A useful first call is {"action":"status"}, then narrow with tail, errors, search, timeline, or context.

Development

npm install
npm run build   # tsc -> dist/
npm test        # node test runner over test/*.test.ts, real temp JSONL files, no network
npm run dev     # run the CLI from source via tsx

License

MIT — see LICENSE.

版本与发布记录

@reneturcios/loglens 共发布 2 个版本,首次发布于 2026/11/02;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.1.0latest2026/11/021 天前
0.0.0-stage2026/11/021 天前

关于 @reneturcios/loglens 的常见问题

@reneturcios/loglens 是什么?

Homelab对本地JSONL日志文件的日志调查:状态、尾部、错误、子字符串搜索、每小时或每天的时间表,以及周围的上下文。一个bin提供一个小型CLI和一个studio MCP服务器,提供单个操作分派工具。

如何安装 @reneturcios/loglens?

在项目目录运行 npm install @reneturcios/loglens,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 loglens,可以用 npx loglens 直接运行。

@reneturcios/loglens 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/reneturcios__loglens 是否存在。

@reneturcios/loglens 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@reneturcios/loglens 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@reneturcios/loglens 可以商用吗?

@reneturcios/loglens 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@reneturcios/loglens 还在维护吗?

最新版本 0.1.0 发布于 2026/11/02(1 天前);至今共发布 2 个版本,其中过去 12 个月发布了 2 个;首次发布于 2026/11/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。