A Ruby gem to compare log files with intelligent normalization of timestamps, GUIDs, and other variable data.
Install the gem:
gem install compare_logsOr add it to your Gemfile:
gem 'compare_logs'Then run:
bundle installCompare the two most recent log files in your Downloads folder:
compare_logsCompare action logs for a specific platform:
compare_logs actions ubuntu-2004Compare specific files:
compare_logs file1.log file2.logShow help:
compare_logs helprequire 'compare_logs'
comparator = CompareLogs::Comparator.new(['file1.log', 'file2.log'])
comparator.runCompareLogs 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.
--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.
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|||IDENTIFIERSee compare_logs.example for more examples. Custom substitutions are applied in addition to the default patterns.
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.
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.0Generate changelog from git commits:
rake changelog:generateThis 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 versionmajor- Bump major version- No label - Bump patch version (default)
Bug reports and pull requests are welcome on GitHub.
The gem is available as open source under the terms of the MIT License.