Skip to content

kaspernyhus/lazylog

Repository files navigation

lazylog

A terminal-based log viewer with search, filtering, and streaming capabilities.

lazylog screenshot

Features

  • Syntax highlighting - Configurable color patterns
  • Search and highlight - Search the entire log file and highlight results
  • Filtering - Include/exclude patterns for filtering lines
  • Event tracking - Define event patterns and track these
  • Stream logs from stdin - Pipe logs directly from any command
  • Save streams - Export stdin streams to files

Installation

Download a precompiled binary for linux here

or build from source by running the install script:

./install.sh

Note: installs to /usr/local/bin/.

For this you need the stable version of the rust toolchain, instructions can be found here.

Usage

View a log file:

lazylog myapp.log

View multiple log files:

lazylog myapp_1.log myapp_2.log

Stream from stdin:

journalctl -f | lazylog

Configuration

Color highlighting patterns can be configured by creating a config.toml file: ~/.config/lazylog/config.toml

Use a custom config file with the -c option:

lazylog -c /path/to/config.toml myapp.log

Load predefined filters from a separate file with the -f or --filters option:

lazylog --filters /path/to/filters.toml myapp.log

Color Configuration

Highlights - Highlight specific patterns within lines:

highlights = [
    { pattern = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}", regex = true },  # IP addresses
    { pattern = "TODO", regex = false, style = { fg = "lightmagenta" } },  # Custom style
]

If no style is specified for highlights, a unique color is auto-assigned.

Events - Color entire lines and track events when patterns match:

events = [
    { name = "Error", pattern = " ERROR ", regex = false, style = { fg = "lightred", bold = true } },
    { name = "Warning", pattern = " WARN", regex = false, style = { fg = "yellow" } },
    { name = "Critical", pattern = " CRITICAL ", critical = true, regex = false, style = { bg = "red" } },
]

Supported colors: red, green, yellow, blue, magenta, cyan, white, black, gray, lightred, lightgreen, lightyellow, lightblue, lightmagenta, lightcyan, darkgray

See examples/config.toml for a complete configuration example and examples/filters.toml for a filters file example.

Development

Clone the repository and build with Cargo:

cargo build

Run the application:

cargo run -- path/to/logfile.log

Run unit tests:

cargo test -- --skip perf

Run performance measurements:

cargo test --release --test perf -- --nocapture --test-threads=1

AI Usage

This project is being developed with AI assistance (thanks Claude). I find AI really useful for exploring design decisions, implementing first drafts and doing massive refactoring quicker than I could have ever done it without these addictive bowling bumpers — the vision and iterative refinements remain driven by me for now. If something feels "generated" it probably is...

About

A terminal-based log viewer with search, filtering, and streaming capabilities

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors