kubectl, terraform, aws, helm — a lot of the DevOps world runs on CLIs.
This module turns the log analyzer into a real command-line tool using Python's
built-in argparse.
app.log— sample loglog_analyzer_cli.py— the CLI tool
python log_analyzer_cli.py --file app.log
python log_analyzer_cli.py --file app.log --out summary.json
python log_analyzer_cli.py --file app.log --level ERROR
python log_analyzer_cli.py --helpIf the file is missing it prints a friendly error and exits with code 2:
$ python log_analyzer_cli.py --file nope.log
Error: log file not found: nope.log
Build the CLI yourself:
- Required
--fileargument. - Optional
--out(output JSON path) and--level(INFO/WARNING/ERROR). - If
--filedoesn't exist, print an error andsys.exit(2). - Count the levels and print the summary (or just
--levelif given). - If
--outis set, write the counts as JSON.