or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-5/

Log File Processor

Build a command-line tool that processes log files line-by-line and generates a summary report at the end of the file.

Requirements

The tool should:

  1. Accept an optional log file path as input. If a file path is provided, process that file. If no file path is provided, read from stdin.
  2. Process the input line-by-line in a memory-efficient streaming manner (do not load the entire file into memory)
  3. Track the following statistics:
    • Total number of lines processed
    • Number of lines containing the text "ERROR" (case-sensitive)
    • Number of lines containing the text "WARN" (case-sensitive)
    • Number of lines containing the text "INFO" (case-sensitive)
  4. When the end of the file (EOF) is reached, output a summary report with all statistics

Note: A single line may contain multiple keywords (e.g., "ERROR: INFO system"). Count each keyword separately.

Output Format

During processing, the tool should remain silent. After processing all lines, it should output:

--- Log Summary ---
Total lines: <count>
Errors: <count>
Warnings: <count>
Info: <count>

Test Cases

  • It processes a file with mixed log levels and outputs correct counts @test
  • It processes stdin input and outputs correct counts @test
  • It correctly detects EOF and outputs summary only once @test

Implementation

@generates

API

// Main entry point - no exports required for CLI tool

Dependencies { .dependencies }

cli { .dependency }

Provides command-line interface and streaming input support.