Skip to content

stringsn88keys/compare_logs

Repository files navigation

CompareLogs

A Ruby gem to compare log files with intelligent normalization of timestamps, GUIDs, and other variable data.

Installation

Install the gem:

gem install compare_logs

Or add it to your Gemfile:

gem 'compare_logs'

Then run:

bundle install

Usage

Command Line

Compare the two most recent log files in your Downloads folder:

compare_logs

Compare action logs for a specific platform:

compare_logs actions ubuntu-2004

Compare specific files:

compare_logs file1.log file2.log

Show help:

compare_logs help

As a Library

require 'compare_logs'

comparator = CompareLogs::Comparator.new(['file1.log', 'file2.log'])
comparator.run

What it Does

CompareLogs normalizes variable data in log files to make meaningful comparisons easier:

  • Timestamps (various formats)
  • GUIDs and GUID-like identifiers
  • Build paths
  • Timing measurements
  • Directory names with timestamps

After normalization, it opens the files in gvimdiff for visual comparison.

Options

  • --aggressive - Remove all lines that are identical in both files after normalization
  • --ignore-versions - Normalize x.y.z version strings to VERSION
  • --ignore-timings - Normalize timing strings (e.g., '1.234 seconds') to TIMING

Options can be combined for maximum noise reduction.

Custom Substitutions

You can add your own custom substitutions using a config file at ~/.compare_logs:

# Format: pattern|||replacement (use ||| as separator)
# One pattern per line, lines starting with # are comments

/my/custom/path/\d+|||CUSTOM_PATH
\b[A-Z]{3,}_\d+\b|||IDENTIFIER

See compare_logs.example for more examples. Custom substitutions are applied in addition to the default patterns.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests.

To install this gem onto your local machine, run bundle exec rake install.

Version Management

Bump versions using rake tasks:

rake version:bump_patch  # x.y.Z
rake version:bump_minor  # x.Y.0
rake version:bump_major  # X.0.0

Generate changelog from git commits:

rake changelog:generate

GitHub Actions

This gem uses GitHub Actions for:

  • CI: Tests on multiple Ruby versions (2.7, 3.0, 3.1, 3.2)
  • Auto Release: On merge to main, automatically:
    • Bumps version (patch by default, minor/major via PR labels)
    • Updates changelog
    • Creates GitHub release
    • Publishes to RubyGems

To control version bumps, add labels to your PRs:

  • minor - Bump minor version
  • major - Bump major version
  • No label - Bump patch version (default)

Contributing

Bug reports and pull requests are welcome on GitHub.

License

The gem is available as open source under the terms of the MIT License.

About

Normalize and compare logs from GitHub Actions downloads, etc.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages