Skip to content

NotTheAmmar/log_processor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Log Processor

A small Rust command-line program that scans a log file in parallel and prints lines containing a target keyword.

The current implementation is tuned for Linux-style system logs. By default it opens /var/log/messages, splits the file into chunks, scans those chunks across multiple threads, and reports every line containing ERROR.

Features

  • Reads large log files using offset-based file reads.
  • Splits work across multiple threads.
  • Avoids splitting log lines in the middle of a chunk.
  • Prints matching lines and a total match count.
  • Uses anyhow for top-level error context.

Requirements

  • Rust toolchain with Cargo.
  • A Unix-like operating system.
  • Read access to the configured log file.

The code currently uses std::os::unix::fs::FileExt, so it is not portable to Windows without changes.

Getting Started

Clone the repository and build it:

cargo build

Run the program:

cargo run

If /var/log/messages is not readable by your user, run against a file you can read by changing these constants in src/main.rs:

const LOG_FILE_PATH: &str = "/var/log/messages";
const TARGET_KEYWORD: &str = "ERROR";

Example Output

ERROR Lines
May 14 12:00:00 host service[123]: ERROR failed to process request
------------------------------
Log File Size (bytes): 1048576
Total occurrences of 'ERROR': 1

Development

Run the test suite:

cargo test

Check formatting:

cargo fmt --check

Run Clippy:

cargo clippy

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages