or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-6/

Log File Analyzer

Build a command-line tool that analyzes log files and generates statistics about error rates and patterns.

Requirements

Your tool should process log files line-by-line and generate statistics about the entries. The tool must:

  1. Accept a file path as a command-line argument
  2. Process the file efficiently line-by-line (important for large log files)
  3. Count different log levels (INFO, WARN, ERROR, DEBUG)
  4. Track the total number of lines processed
  5. Output the statistics after processing the entire file

Log File Format

Each line in the log file follows this format:

[LEVEL] message text

Where LEVEL is one of: INFO, WARN, ERROR, or DEBUG

Example Input

[INFO] Application started
[DEBUG] Loading configuration
[ERROR] Failed to connect to database
[WARN] Retrying connection
[INFO] Connection established
[ERROR] Invalid user input
[DEBUG] Processing request

Expected Behavior

  • Process log files of any size without loading the entire file into memory
  • Provide accurate counts for each log level
  • Handle edge cases like empty files or malformed lines gracefully
  • Display results in a clear format

Test Cases

  • Given a file with 3 INFO, 2 ERROR, 1 WARN, and 2 DEBUG entries, the tool correctly counts each level @test
  • Given an empty file, the tool processes it without errors and reports zero counts @test
  • Given a file with lines not matching the expected format, the tool processes it without crashing @test

Implementation

@generates

Dependencies { .dependencies }

cli { .dependency }

Provides command-line interface utilities for argument parsing and file input processing.