docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a command-line tool that processes log files to extract and count error messages by severity level.
Your tool should accept a log file path as a command-line argument using the -f or --file option. When no file is provided, the tool should read from standard input (stdin).
The tool should process the input line-by-line and:
LEVEL: countLog lines follow this format: [TIMESTAMP] LEVEL: message
For example:
[2025-01-15 10:23:45] ERROR: Database connection failed
[2025-01-15 10:23:46] WARN: Retry attempt 1
[2025-01-15 10:23:47] INFO: Connection restoredThe tool should handle large files efficiently by processing them line-by-line without loading the entire file into memory.
ERROR: 3, WARN: 2, INFO: 1 @testDEBUG: 2 @test/**
* Processes log file or stdin and counts severity levels
* @param {string} filePath - Path to log file, or null for stdin
* @param {function} callback - Called with severity counts object
*/
function analyzeLog(filePath, callback) {
// Implementation
}
module.exports = { analyzeLog };Provides command-line argument parsing and line-by-line input streaming capabilities.