log_parser_kma

Crates.iolog_parser_kma
lib.rslog_parser_kma
version0.1.3
sourcesrc
created_at2024-11-13 18:58:25.35756
updated_at2024-11-13 23:28:57.814765
descriptionRust-based log file parser, helping extract datetime, log levels and messages
homepage
repository
max_upload_size
id1446934
size35,879
Krachylo Illia (gra4444)

documentation

README

Log Parser

Log Parser is a simple Rust-based log file parser that uses pest crate to parse log files, helping with extracting datetime, log levels and messages.

Log Parser can be used to extract logs with specified log level into another file OR/AND into json format using serde.

Format

Logs are parsed in the following format: Date Time Level Message.

  • Date - date specified in YYYY-MM-DD format, e.g. 2024-11-07.
  • Time - time specified in HH:MM:SS format, e.g. 15:41:07.
  • Level - one of three (currently) logging levels: INFO, WARNING, ERROR.
  • Message - message of the log line.

CLI Usage

Log parser can be used via CLI (created using clap) with the following options:

Parse command

log_parser_kma parse -f <file_path> -o <output_path> [options]

Options

  • -f, --file <file_path> - specifies the path to the log file to be parsed. (Required)
  • -o, --output <output_path> - specifies the path to the output file. (Required)
  • -l, --level <log_level> - specifies log level to filter by (INFO, WARNING or ERROR). (Optional)
  • -j, --to-json - outputs the logs in JSON format instead of plain text. (Optional)

Examples

Parse a log file and save output as JSON

log_parser_kma parse -f logs.log -o results.txt -j

Parse a log file, filter ERROR level logs and output as JSON

log_parser_kma parse -f newlogs.log -o errorlogs.txt -l ERROR -j

Help command

log_parser_kma help

Credits command

log_parser_kma credits

Published on

Commit count: 0

cargo fmt