Communitygithub.com

cli-anything-nslogger

NSLogger 的命令列工具 — 解析、篩選、匯出與監控 NSLogger 日誌檔案(.rawnsloggerdata / .nsloggerdata)

cli-anything-nslogger 是什麼?

此技能提供一個完整的命令列工具(CLI harness)來操作 NSLogger 日誌格式,NSLogger 是 macOS 上用來檢視 iOS/macOS 應用程式日誌的工具。開發者或 AI 代理可以透過此技能生成測試用的範例日誌檔案、從已儲存的日誌檔案讀取與篩選訊息(支援層級、標籤、正規表示式搜尋),並將結果匯出為文字、JSON 或 CSV 格式。此工具還支援 `listen` 指令,可以透過 Bonjour 或直接 TCP/TLS 連線即時接收來自 iOS 應用的日誌串流,模擬 NSLogger GUI 的行為,是除錯與自動化分析日誌的理想選擇。支援的平台包括 macOS(原生命令列)與任何可執行 Python 的環境。此技能特別適合用於自動化錯誤分析、即時監控應用狀態,以及在 CI/CD 流程中整合日誌處理。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/HKUDS/CLI-Anything/tree/main/skills/cli-anything-nslogger

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

cli-anything-nslogger 是做什麼的?

一個完整的命令列工具(CLI harness),用於 NSLogger — macOS 上 iOS/macOS 應用程式的日誌檢視器。

安裝

cd nslogger/agent-harness
pip install -e .
# 驗證
cli-anything-nslogger --help

指令參考

generate — 建立用於測試的範例檔案

cli-anything-nslogger generate sample.rawnsloggerdata --count 50

read — 顯示檔案中的訊息

# 所有訊息
cli-anything-nslogger read session.rawnsloggerdata

# 僅錯誤(層級 0)
cli-anything-nslogger read session.rawnsloggerdata --level 0

# 依標籤與文字搜尋過濾
cli-anything-nslogger read session.rawnsloggerdata --tag Network --search "timeout"

# 前 20 則訊息,輸出為 JSON
cli-anything-nslogger read session.rawnsloggerdata --limit 20 --json

filter — 進階過濾

# 僅錯誤與警告
cli-anything-nslogger filter session.rawnsloggerdata --level 1

# 依標籤
cli-anything-nslogger filter session.rawnsloggerdata --tag Auth --tag Network

# 正規表示式搜尋
cli-anything-nslogger filter session.rawnsloggerdata --regex "(timeout|failed|error)"

# 依執行緒
cli-anything-nslogger filter session.rawnsloggerdata --thread "main"

# JSON 輸出
cli-anything-nslogger filter session.rawnsloggerdata --level 0 --json

export — 匯出為文字/JSON/CSV

# JSON 輸出到標準輸出
cli-anything-nslogger export session.rawnsloggerdata --format json

# CSV 輸出到檔案
cli-anything-nslogger export session.rawnsloggerdata --format csv --output logs.csv

# 過濾後文字匯出
cli-anything-nslogger export session.rawnsloggerdata --format text --level 1 --tag Network

stats — 摘要統計

# 人類可讀的摘要
cli-anything-nslogger stats session.rawnsloggerdata

# 供代理使用的 JSON 格式
cli-anything-nslogger stats session.rawnsloggerdata --json

JSON 輸出形狀:

{
  "total": 342,
  "by_level": {"ERROR": 12, "WARNING": 34, "INFO": 200, "DEBUG": 96},
  "by_tag": {"Network": 89, "Auth": 45, "UI": 120},
  "by_thread": {"main": 200, "bg-queue": 142},
  "by_type": {"text": 340, "client_info": 1, "disconnect": 1},
  "clients": ["MyApp"],
  "first_timestamp": "2024-01-01T10:00:00+00:00",
  "last_timestamp": "2024-01-01T10:05:30+00:00",
  "duration_seconds": 330.0
}

listen — 接收即時連線

# 比對 NSLogger.app GUI Bonjour 行為,用於 iOS 自動發現
cli-anything-nslogger listen --bonjour --name bazinga --debug

# 將即時日誌鏡像到文字檔案,同時仍列印到標準輸出
cli-anything-nslogger listen --bonjour --name bazinga --output app.log

# 寫入機器可讀的 JSON Lines
cli-anything-nslogger listen --bonjour --name bazinga --output app.jsonl --output-format jsonl

# 直接 TCP/TLS 模式,用於手動設定的客戶端
cli-anything-nslogger listen --port 50000 --ssl --debug

# 監聽時僅顯示錯誤,輸出為 JSON 串流
cli-anything-nslogger listen --bonjour --name bazinga --level 0 --json

# 持續執行直到按下 Ctrl-C
cli-anything-nslogger listen --bonjour --name bazinga

對於 iOS 應用,請優先使用 Bonjour 模式,因為它與桌面 NSLogger GUI 的行為一致: CLI 會發布一個原生的 macOS NetService,使用 _nslogger-ssl._tcp 協定, 並接受 TLS NSLogger 幀。只有在應用程式已手動設定 Mac 主機與連接埠時,才使用直接 TCP/TLS 模式。

repl — 互動式指令 REPL

cli-anything-nslogger repl session.rawnsloggerdata
# 或者直接執行 cli-anything-nslogger(不帶子指令)即可啟動。

日誌層級

值名稱用途
0ERROR無法復原的失敗
1WARNING可復原的問題
2INFO正常運作
3DEBUG開發人員細節
4VERBOSE追蹤等級的雜訊

訊息 JSON 形狀

{
  "sequence": 42,
  "timestamp": "2024-01-01T10:01:23+00:00",
  "timestamp_ms": 456,
  "thread_id": "main",
  "tag": "Network",
  "level": 0,
  "level_name": "ERROR",
  "type": "text",
  "text": "Connection timed out after 30s",
  "image_width": 0,
  "image_height": 0,
  "client_name": "MyApp",
  "client_version": "2.1.0",
  "os_name": "iOS",
  "os_version": "17.0",
  "machine": "iPhone15,2"
}

代理工作流程範例

# 1. 檢查捕獲的崩潰工作階段
cli-anything-nslogger stats crash.rawnsloggerdata --json

# 2. 找出崩潰前 5 分鐘內的所有錯誤
cli-anything-nslogger filter crash.rawnsloggerdata --level 0 --json

# 3. 僅取得網路失敗
cli-anything-nslogger filter crash.rawnsloggerdata --tag Network --regex "fail|timeout|error" --json

# 4. 匯出完整日誌供離線分析
cli-anything-nslogger export crash.rawnsloggerdata --format json --output crash_log.json

# 5. 即時監控 iOS 應用並保留本機副本
cli-anything-nslogger listen --bonjour --name bazinga --output app.log --debug

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

cli-anything-adguardhome

>-

cli-anything-anygen

>-

cli-anything-audacity

>-

cli-anything-blender

>-

cli-anything-browser

Browser automation CLI using DOMShell MCP server. Maps Chrome

cli-anything-calibre

>-

cli-anything-ccswitch

CLI interface for CC Switch — manage AI coding tool configurations from the terminal

cli-anything-chromadb

>-

cli-anything-cloudanalyzer

Command-line interface for CloudAnalyzer — Agent-friendly harness for CloudAnalyzer, a QA platform for mapping, localization, and perception outputs. Supports 27 commands across 8 groups: point cloud evaluation, trajectory evaluation, ground segmentation QA, config-driven quality gates, baseline evolution, processing, visualization, and interactive REPL.

cli-anything-cloudcompare

Command-line interface for CloudCompare — Agent-friendly harness for CloudCompare, the open-source 3D point cloud and mesh processing software. Supports 41 commands across 9 groups: project management, session control, point cloud operations (subsample, filter, segment, analyze), mesh operations, distance computation (C2C, C2M), transformations (ICP, matrix), export (LAS/LAZ/PLY/PCD/OBJ/STL/E57), and interactive REPL.

cli-anything-comfyui

>-

cli-anything-dify-workflow

Wrapper for the Dify workflow DSL CLI. Create, inspect, validate, edit, and export Dify workflow files through a CLI-Anything harness.

cli-anything-drawio

>-

cli-anything-eez-studio

Use EEZ Studio from the command line: inspect and modify native .eez-project files, edit LVGL screens/widgets, manage SCPI commands, and invoke the real EEZ Studio backend for LVGL builds.

cli-anything-eth2-quickstart

>-

cli-anything-exa

>-

cli-anything-firefly-iii

Firefly III CLI - Personal finance management via CLI-Anything

cli-anything-freecad

Complete CLI harness for FreeCAD parametric 3D CAD modeler (258 commands). Covers ALL workbenches: Part (29 primitives + boolean + mirror + loft + sweep), Sketcher (26 cmds: geometry + constraints + editing), PartDesign (38 cmds: pad/pocket/groove/fillet/chamfer/patterns/hole/datum), Assembly (11 cmds), Mesh (16 cmds), TechDraw (15 cmds: views + dimensions + PDF/SVG), Draft (33 cmds: 2D shapes + arrays + transforms), FEM (12 cmds), CAM/CNC (10 cmds), Surface (6 cmds), Spreadsheet (7 cmds), Import (13 formats), Export (17 formats), Measure (12 cmds), Materials (21 presets). Headless FreeCAD export to STEP/IGES/STL/OBJ/DXF/PDF/glTF/3MF.

cli-anything-gimp

>-

cli-anything-godot

>-

相關技能