biruk741

structured-logging

Zero-dependency structured log format with timestamps. Optimized for grep, supports high-volume apps.

biruk741 0 Updated 3mo ago
GitHub

Install

npx skillscat add biruk741/cc-plugins/structured-logging

Install via the SkillsCat registry.

SKILL.md

Structured Debugging Log Format

Format Specification

[DD:{session}:{vc}:{component}:{type}:{timestamp}] {json}
Segment Description Example
DD Prefix (literal) DD
session Session ID s1, s2
vc Verification Condition VC1, VC0 (general)
component Module/Component LoginForm, useAuth
type Log type STATE, RENDER, ERROR
timestamp Unix ms 1707091234567

Log Types

Type When to Use
STATE Variable/state capture
RENDER Component render
EFFECT useEffect/lifecycle
ENTRY Function entered
EXIT Function exited
ASYNC Async operation
ERROR Error/exception
BRANCH Conditional taken
EVENT Event handler
NAV Navigation change

JSON Payload

{
  "ts": 1707091234567,
  "elapsed": 2847,
  // ... context fields
}

Grep Patterns

# All debug logs
grep '\[DD:' logs.log

# Specific session
grep '\[DD:s1:' logs.log

# Specific VC
grep '\[DD:s1:VC1' logs.log

# Specific component
grep '\[DD:s1:VC1:LoginForm' logs.log

# All errors
grep '\[DD:s1:.*:ERROR' logs.log

# Sort by timestamp
grep '\[DD:s1:' logs.log | sort -t: -k6 -n

# Count events
grep -c '\[DD:s1:VC1' logs.log

Log Capture Commands

# React (web)
yarn start 2>&1 | tee .debug-state/logs/s1.log

# React Native (Metro)
npx react-native start 2>&1 | tee .debug-state/logs/s1.log

# React Native (device)
npx react-native log-android 2>&1 | tee .debug-state/logs/s1.log
npx react-native log-ios 2>&1 | tee .debug-state/logs/s1.log

Timing Analysis

# Find slow gaps (>1000ms between events)
grep '\[DD:s1:' logs.log | awk -F: '{print $6}' | \
  awk 'NR>1{print $1-prev} {prev=$1}' | awk '$1>1000'

# Duration between entry/exit
START=$(grep '\[DD:s1:VC1:Login:ENTRY' logs.log | head -1 | grep -oP ':\d{13}]' | tr -d ':[]')
END=$(grep '\[DD:s1:VC1:Login:EXIT' logs.log | head -1 | grep -oP ':\d{13}]' | tr -d ':[]')
echo "Duration: $(($END - $START))ms"