Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

log-coverage-analyzer日志覆盖率分析器

Agent Skill

log-coverage-analyzer 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

1,018

周安装

42

GitHub Stars

18

下载量

333
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:log-coverage-analyzer(日志覆盖率分析器)
来源仓库:https://github.com/openharmonyinsight/openharmony-skills
仓库路径:skills/log-coverage-analyzer
安装命令:
npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill log-coverage-analyzer
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill log-coverage-analyzer

简介

log-coverage-analyzer 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中根据关键词、任务场景或来源线索快速定位候选结果时使用。

  • 适用于代码质量评估与测试充分性分析。
  • 可获取覆盖率报告解读方法、低覆盖模块识别技巧或提升策略。
  • 安装命令为 npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill log-coverage-analyzer。
  • 不同语言项目的覆盖率标准可能存在差异,需结合上下文判断。

SKILL.md

This skill performs comprehensive log coverage analysis for code repositories. It identifies logging deficiencies in call chains and detects high-frequency log risks that may impact performance.

Analysis Principles

Log Level Definitions

Log LevelBehaviorUse Case
LOGEAlways prints, never lostCritical - Must exist on all error return paths
LOGIAlways prints, may be lost if high-frequency triggered at same locationImportant - Success paths, key operations
LOGDOnly prints when debug switch enabledOptional - Debug information only
LOGWOnly prints when debug switch enabledOptional - Warning information only

Core Analysis Rules

  1. Log Coverage Rule: Each branch in a function call chain must have LOGE or LOGI level logging
  2. High-Frequency Risk Rule: Functions that may be called frequently (loops, timers, callbacks, event handlers) with LOGE/LOGI logs pose performance risks
  3. Error Path Rule: All error return paths MUST have LOGE logging
  4. Context Rule: All logs must include sufficient context information (IDs, states, parameters)

Execution Workflow

Step 00: Create Analysis Plan

Description: Create detailed analysis plan before starting

Actions:

  • Use TodoWrite tool to create task list
  • Plan analysis scope:

- Source file discovery and filtering - Function call chain extraction - Log coverage analysis per branch - High-frequency risk detection - Report generation

Output: Analysis plan created via TodoWrite tool

Step 01: Discover Source Files

Description: Find all relevant source files in the repository

Actions:

  • Use Glob tool to find source files based on language patterns:

- C/C++: **/*.cpp, **/*.cc, **/*.cxx, **/*.h, **/*.hpp - Java: **/*.java - Python: **/*.py - JavaScript/TypeScript: **/*.js, **/*.ts - Go: **/*.go - Rust: **/*.rs

  • Exclude test files if specified (patterns: **/test/**, **/tests/**, **/*_test.*)
  • Exclude build directories (patterns: **/build/**, **/out/**, **/target/**)

Output: List of source files to analyze

Step 02: Scan Logging Patterns

Description: Scan all source files for logging macros/functions

Actions:

  • Use Grep tool to find log statements with pattern:

- Case-insensitive search for: LOG[DEIW], HILOG[DEIW], ALOG[DEIW] - Also search for: \.log[deiw]\(, Log\.[deiw], LOG\.

  • Count occurrences per file
  • Identify log level distribution

Output: Log statistics per file

Step 03: Extract Functions and Call Chains

Description: Parse source files to extract function definitions and call relationships

Actions:

  • For each source file:

- Identify function definitions (various patterns per language) - Extract function bodies including all branches - Identify function calls within each function - Build call chain graph

  • Map branch conditions (if/else, switch/case, try/catch, early returns)

Output: Function list with call relationships

Step 04: Analyze Log Coverage per Branch

Description: Check each branch in call chains for required logging

Actions:

  • For each function in call chain:

- Identify all branches: - Early returns - if/else branches - switch/case branches - try/catch blocks - loop exits with error conditions - Check each branch for LOGE or LOGI presence - Flag branches without required logging as Log Deficiency - Check error return paths specifically for LOGE

Deficiency Classification:

  • High Priority: Error return path without LOGE
  • Medium Priority: Success path without LOGI for multi-step operations
  • Low Priority: Branch without any logging (non-critical)

Output: List of log deficiencies with locations

Step 05: Detect High-Frequency Log Risks

Description: Identify functions with LOGE/LOGI that may be called frequently

Actions:

  • Identify high-frequency function patterns:

- Network data callbacks (OnDataReceived, OnPacketReceived, OnMessage) - Timer callbacks (OnTimer, Tick, Update) - Event handlers (HandleEvent, ProcessEvent, OnEvent) - Loop operations (ProcessItem, HandlePacket, SendData) - Stream processing (ProcessStream, HandleFrame, EncodeFrame) - Message queue handlers (OnMessage, Dispatch)

  • For functions with LOGE/LOGI in these patterns:

- Analyze call frequency potential - Classify risk level: High/Medium/Low - Flag as High-Frequency Risk

Risk Classification:

  • High Risk: Per-packet/per-frame LOGE/LOGI in data path
  • Medium Risk: Per-message LOGI in messaging path
  • Low Risk: Low-frequency callbacks with logs

Output: List of high-frequency risks with locations

Step 06: Generate Analysis Report

Description: Create comprehensive analysis report with all findings

Actions:

  • Generate Markdown report with:

1. Summary statistics 2. Log deficiencies with fix suggestions 3. High-frequency risks with fix suggestions 4. Call chain analysis 5. Detailed code examples

  • Use Write tool to save report to log-coverage-report-YYYYMMDD-HHmmss.md

Output: Complete analysis report

Language-Specific Patterns

C/C++

Function Definition Patterns:

[return_type] [class::]function_name([parameters]) {
[\w\s:*,]*\{

Log Patterns:

  • LOG[DEIW]\(, HILOG[DEIW]\(, ALOG[DEIW]\(
  • __android_log_print
  • OHOS::HiviewDFX::HiLog::[Error|Warn|Info|Debug]

Java

Function Definition Patterns:

(public|private|protected)?(\s+static)?\s+\w+\s+\w+\s*\(.*\)\s*(throws\s+[\w\s,]+)?\s*\{

Log Patterns:

  • Log\.[deiw]\(
  • Logger\.(error|warn|info|debug)\(
  • Timber\.[deiw]\(

Python

Function Definition Patterns:

def\s+\w+\s*\(.*\)\s*->?\s*.*:

Log Patterns:

  • logger\.(error|warning|info|debug)\(
  • logging\.(error|warning|info|debug)\(
  • print\(

JavaScript/TypeScript

Function Definition Patterns:

function\s+\w+\s*\(.*\)\s*\{
|\w+\s*\([^)]*\)\s*(=>|\{)

Log Patterns:

  • console\.(error|warn|info|log)\(
  • logger\.(error|warn|info|debug)\(

Fix Recommendations

For Log Deficiencies

Error Return Path (Must Fix):

// BEFORE:
if (remote == nullptr) {
    return ERR_NULL_OBJECT;  // ❌ No LOGE
}

// AFTER:
if (remote == nullptr) {
    HILOGE("FunctionName: remote is null, context=%{public}d", context);
    return ERR_NULL_OBJECT;
}

Success Path (Should Fix):

// BEFORE:
int32_t CreateSession(...) {
    // ... initialization code
    return ERR_OK;  // ❌ No LOGI on success
}

// AFTER:
int32_t CreateSession(...) {
    // ... initialization code
    HILOGI("CreateSession: success, sessionId=%{public}d, name=%{public}s", id, name);
    return ERR_OK;
}

For High-Frequency Risks

Remove High-Frequency LOGI:

// BEFORE:
void OnPacketReceived(int socketId, const void* data, uint32_t len) {
    HILOGI("packet received: socket=%{public}d, len=%{public}u", socketId, len);  // ⚠️ Per-packet
    // ... process packet
}

// AFTER:
void OnPacketReceived(int socketId, const void* data, uint32_t len) {
    // Removed per-packet LOGI
    static std::atomic<uint64_t> packetCount{0};
    if (++packetCount % 1000 == 1) {
        HILOGI("Packet stats: count=%{public}llu, socket=%{public}d",
            packetCount.load(), socketId);
    }
    // ... process packet
}

Use Throttled LOGE for Errors:

// BEFORE:
void ProcessPacket(const Packet* pkt) {
    if (pkt == nullptr) {
        HILOGE("packet is null");  // ⚠️ Per-packet error
        return;
    }
}

// AFTER:
void ProcessPacket(const Packet* pkt) {
    if (pkt == nullptr) {
        static std::atomic<uint32_t> errorCount{0};
        if (++errorCount % 100 == 1) {
            HILOGE("ProcessPacket: null packet, count=%{public}u", errorCount.load());
        }
        return;
    }
}

Output Format

================================================================================
Log Coverage Analysis Report
================================================================================

Repository: <repository_path>
Analysis Date: <timestamp>
Files Analyzed: <count>

## Summary Statistics

| Metric | Count |
|--------|-------|
| Total Source Files | <number> |
| Total Functions | <number> |
| Functions Analyzed | <number> |
| Log Deficiencies | <number> |
| High-Frequency Risks | <number> |

## Log Deficiencies

### [High/Medium/Low] Priority

**File**: `<file_path>`
**Function**: `<function_name>`
**Lines**: `<line_range>`
**Issue**: `<description>`

**Evidence**:

<code snippet>


**Impact**: <explain impact on debugging/troubleshooting>

**Fix**:

<fixed code>


---

## High-Frequency Risks

### [High/Medium/Low] Risk

**File**: `<file_path>` **Function**: `<function_name>` **Lines**: `<line_range>` **Risk**:

**Evidence**:

<code snippet>


**Analysis**:

**Fix**:

<fixed code with throttling/statistics>


---

## Call Chain Analysis

### Call Chain: <chain_name>

<function_1>() ↓ [✓/✗/⚠️] <log_status> <function_2>() ↓ [✓/✗/⚠️] <log_status> <function_3>() ├─ [✓/✗/⚠️] branch_1 ├─ [✓/✗/⚠️] branch_2 └─ [✓/✗/⚠️] branch_3


Legend:

- ✓: Has required LOGE/LOGI
- ✗: Missing required logging
- ⚠️: Has high-frequency log risk

---

## Recommendations

### Immediate Actions (P0)

### Follow-up Actions (P1)

### Long-term Improvements (P2)

================================================================================

Parameters

ParameterRequiredDescription
--pathNoRepository path (default: current directory)
--exclude-testsNoExclude test files (default: true)
--langNoLanguage filter (cpp, java, python, js, all)
--outputNoOutput report path

Usage Examples


# Analyze current directory

/log-coverage-analyzer

# Analyze specific repository

/log-coverage-analyzer --path /path/to/repo

# Analyze C++ code only

/log-coverage-analyzer --lang cpp --path /path/to/repo

# Include test files in analysis

/log-coverage-analyzer --exclude-tests false

# Custom output location

/log-coverage-analyzer --output /path/to/report.md

Tips

  • Use Grep with output_mode: content and -B/-C flags for context
  • Use Read tool with offset and limit for large files
  • For large repositories, focus on critical directories first
  • High-frequency risks should be prioritized over minor log deficiencies
  • Always include context (IDs, states, parameters) in LOGE messages

适合场景

01

研究助手

02

事实核查

03

知识库问答

04

带来源的搜索总结

能力概览

能力 1

组合搜索和大模型调用

能力 2

支持多来源检索和总结

能力 3

强调引用来源和事实核查

能力 4

适合研究型 Agent 流程

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.8%
按下载量换算126

Claude

28.33%
按下载量换算94

Cursor

19.42%
按下载量换算65

Gemini CLI

8.67%
按下载量换算29

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills