Skip to content
log-summary-date-ranges logo

Log Summary Date Ranges

log-summary-date-ranges

This skill provides guidance for analyzing log files across date ranges and producing summary statistics. Use when tasks involve parsing log files, counting log entries by severity (ERROR, WARNING, INFO), aggregating by date ranges (today, last N days, month-to-date), or producing CSV reports fro...

SKILL.md

Full skill instructions

Log Summary Date Ranges

Overview

This skill guides log file analysis tasks that require aggregating entries across different date ranges and producing summary reports. Common scenarios include counting log entries by severity level (ERROR, WARNING, INFO) for various time periods and outputting results in structured formats like CSV.

Workflow

Step 1: Understand the Data Structure

Before writing any analysis code:

  1. Examine the log directory structure - Identify how log files are organized (by date, by service, flat structure)
  2. Identify the naming pattern - Log files often follow patterns like app-YYYY-MM-DD.log or service.log.YYYY-MM-DD
  3. Parse sample log entries - Understand the exact format of log lines:
    • Timestamp format (ISO 8601, Unix timestamp, custom)
    • Severity level position and format (uppercase, lowercase, bracketed)
    • Delimiter between fields

Example log entry formats:

2025-08-12 10:30:45 ERROR Database connection failed
[2025-08-12T10:30:45.123Z] [ERROR] Database connection failed
ERROR 2025-08-12 10:30:45 - Database connection failed

Step 2: Calculate Date Ranges Correctly

Given a reference date, calculate inclusive date ranges:

RangeCalculationExample (ref: 2025-08-12)
Todayreference date only2025-08-12
Last 7 daysreference - 6 days to reference2025-08-06 to 2025-08-12
Last 30 daysreference - 29 days to reference2025-07-14 to 2025-08-12
Month to datefirst of month to reference2025-08-01 to 2025-08-12

Critical consideration: Clarify whether ranges are inclusive or exclusive at boundaries. "Last 7 days" typically means today plus the 6 preceding days (7 total days).

Step 3: Implement the Analysis

When writing the analysis script:

  1. File selection - Filter log files by date extracted from filename or file metadata
  2. Entry parsing - Extract timestamp and severity from each log line
  3. Date matching - Determine which date range(s) each entry belongs to
  4. Aggregation - Count entries by severity for each date range
  5. Output formatting - Produce output in the required format (CSV, JSON, etc.)

Step 4: Verify Results Independently

Always verify results using independent methods:

  1. Spot-check individual counts - Use grep/​awk to count specific severities for specific dates
  2. Verify boundary dates - Test entries at range boundaries (first/​last day of each range)
  3. Check totals - Sum of individual day counts should equal range totals
  4. Validate all ranges - Do not verify only "today" and "total"; verify intermediate ranges too

Example verification commands:

# Count ERROR entries for a specific date
grep "2025-08-12" logs/​*.log | grep -c "ERROR"

# Count all ERROR entries
grep -r "ERROR" logs/ | wc -l

# Verify a specific file's contribution
grep -c "ERROR" logs/​app-2025-08-12.log

Common Pitfalls

Date Range Calculation Errors

  • Off-by-one errors - "Last 7 days" should include 7 days, not 6 or 8
  • Timezone issues - Log timestamps may be in different timezone than reference date
  • Inclusive vs exclusive - Clarify whether end dates are included in ranges

Output Format Issues

  • Line endings - Use Unix-style \n unless Windows format is explicitly required. Configure CSV writers properly:
    # Python: Prevent Windows line endings
    with open('output.csv', 'w', newline='') as f:
        writer = csv.writer(f)
    
  • Quoting - Ensure CSV fields with commas or quotes are properly escaped
  • Column order - Match the exact column order specified in requirements

Parsing Issues

  • Case sensitivity - Severity levels may appear as "ERROR", "error", or "Error"
  • Multiple matches per line - A log line mentioning "ERROR in error handler" should count once
  • Malformed entries - Gracefully handle log lines that don't match expected format
  • Empty files - Log files may exist but be empty; handle this case

Verification Gaps

  • Partial verification - Verifying only endpoints (today, total) may miss bugs in intermediate ranges
  • Incomplete code review - Ensure the full analysis script is visible and reviewable
  • No independent validation - Always cross-check results with simple grep/​awk commands

Verification Checklist

Before declaring the task complete:

  • All date range boundaries calculated correctly
  • Sample entries from each range verified manually
  • Output format matches specification exactly (columns, line endings, quoting)
  • Edge cases handled (empty files, malformed entries, missing dates)
  • Independent verification performed for each severity level
  • Intermediate ranges verified (not just endpoints)
  • Temporary files cleaned up (scripts, intermediate outputs)

Resources

references/

See references/​date_range_patterns.md for common date range calculation patterns and edge cases.

scripts/

No scripts are bundled. Analysis scripts should be written based on the specific log format and requirements of each task.

assets/

No assets are bundled with this skill.

More Productivity & Planning skills

brainstorming logo
Productivity & Planning

brainstorming

Structured design dialogue that validates ideas before implementation begins.

295.4K 385.7K
View
ui-ux-pro-max logo
Productivity & Planning

ui-ux-pro-max

Comprehensive design intelligence for web and mobile UI/UX across 10 technology stacks.

133.1K 383.9K
View
writing-plans logo
Productivity & Planning

writing-plans

Comprehensive implementation plans for multi-step tasks, breaking down specs into bite-sized, testable steps.

295.4K 268K
View
using-superpowers logo
Productivity & Planning

using-superpowers

Introduction to the obra skills system with mandatory skill invocation rules and best practices.

295.4K 259.8K
View
executing-plans logo
Productivity & Planning

executing-plans

Execute a written implementation plan with critical review and task checkpoints.

295.4K 229.1K
View
dispatching-parallel-agents logo
Productivity & Planning

dispatching-parallel-agents

Delegate independent tasks to specialized agents working concurrently with isolated context.

295.4K 206.3K
View
using-git-worktrees logo
Productivity & Planning

using-git-worktrees

Isolated git worktrees with smart directory selection and safety verification.

295.4K 205.2K
View
webapp-testing logo
Productivity & Planning

webapp-testing

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

179.7K 170.6K
View
content-strategy logo
Productivity & Planning

content-strategy

Plan searchable and shareable content that drives traffic, builds authority, and generates leads.

53.3K 150.9K
View
repo-intake-and-plan logo
Productivity & Planning

repo-intake-and-plan

README-first repository scanner that extracts commands and classifies reproduction candidates without executing them.

497 139.6K
View
marketing-ideas logo
Productivity & Planning

marketing-ideas

Brainstorm and prioritize marketing strategies tailored to your SaaS stage, budget, and goals.

53.3K 137.2K
View
site-architecture logo
Productivity & Planning

site-architecture

Plan and optimize your website's page hierarchy, navigation, URL structure, and internal linking.

53.3K 112.8K
View

Productivity AI tools

Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View
SaveDay logo
Productivity

SaveDay

Capture, organize, and utilize your knowledge effortlessly.

Free
View
Any Summary logo
Productivity

Any Summary

Instant Summaries of Audio & Video Interviews with AnySummary

Freemium
View
M
Productivity

Map This

Transform PDFs into engaging mind maps.

Freemium
View
ChatPDF logo
Productivity

ChatPDF

Chat with any PDF instantly

Free
View
I
Productivity

intellisay

Create an optimal daily plan using your voice

Paid
View
A
Productivity

Aurora AI

A productivity platform to centralize organizational knowledge and workflows with contextual AI assistance.

Paid
View
AskYourPDF logo
Productivity

AskYourPDF

AskYourPDF Pricing Plans: Tailored to Your Needs

Free
View