or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-8/

Log Analyzer CLI Tool

Build a command-line tool that reads log data from standard input and produces statistical summaries. The tool should process log entries and output analysis results.

Functionality

The application should:

  1. Accept log data via standard input (STDIN) where each line represents a log entry in the format: [LEVEL] message text
  2. Parse each line to extract the log level (INFO, WARN, ERROR, DEBUG)
  3. Count the occurrences of each log level
  4. Output a summary showing the count for each log level found
  5. Handle empty input gracefully by outputting "No log entries found"

Input Format

Log entries will be provided via STDIN, one per line:

[INFO] Application started
[WARN] Configuration file not found, using defaults
[ERROR] Failed to connect to database
[INFO] Server listening on port 3000
[DEBUG] Processing request

Output Format

The tool should output a summary in this format:

Log Analysis Summary:
INFO: 2
WARN: 1
ERROR: 1
DEBUG: 1

The log levels should be displayed in alphabetical order. If no entries are found, output: No log entries found

Implementation Requirements

  • Use standard input processing to read log data
  • Extract log levels from each line (text between [ and ])
  • Count occurrences of each log level
  • Display results sorted alphabetically by log level
  • Handle edge cases like empty input or malformed lines gracefully (skip malformed lines)

Test Cases

  • When provided with 5 log entries containing 2 INFO, 1 WARN, 1 ERROR, and 1 DEBUG entry, outputs correct counts for each level @test
  • When provided with empty input (no lines), outputs "No log entries found" @test
  • When provided with mixed valid and malformed entries, counts only valid entries and skips malformed ones @test

@generates

API

// No exported API required - this is a CLI tool that reads from stdin

Dependencies { .dependencies }

cli { .dependency }

Provides command-line interface utilities including standard input processing.