0.0
The project is in a healthy, maintained state
A mountable Rails engine that provides a beautiful web interface for viewing and understanding your Rails logs. Groups requests with their SQL queries and view renders, with real-time updates.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

 Project Readme

Trainspotter

A zero-config, web-based Rails log viewer with request grouping and session tracking. See your Rails logs in a beautiful, organized interface right in your browser.

Features

  • Zero configuration - Just mount the engine and go
  • Request grouping - See HTTP requests with their associated SQL queries and view renders
  • Session tracking - Group requests by user session with automatic login/logout detection
  • Real-time updates - New requests appear automatically via polling
  • Background processing - Log ingestion runs in a background job
  • SQLite storage - Separate database for fast queries without impacting your app
  • Dark/light mode - Respects your system preference
  • Performance at a glance - See request duration, query count, and render count

Installation

Add this line to your application's Gemfile:

gem "trainspotter"

And then execute:

bundle install

Usage

Mount the engine in your config/routes.rb:

Rails.application.routes.draw do
  mount Trainspotter::Engine => "/admin/logs"

  # Your other routes...
end

That's it! Visit /trainspotter in your browser to see your logs.

Restricting Access

In production, you'll likely want to restrict access. Here are some options:

With Devise:

authenticate :user, ->(u) { u.admin? } do
  mount Trainspotter::Engine => "/trainspotter"
end

With HTTP Basic Auth:

mount Trainspotter::Engine => "/trainspotter", constraints: ->(req) {
  Rack::Auth::Basic::Request.new(req.env).provided? &&
  Rack::Auth::Basic::Request.new(req.env).credentials == ["admin", ENV["TRAINSPOTTER_PASSWORD"]]
}

Development only:

if Rails.env.development?
  mount Trainspotter::Engine => "/trainspotter"
end

How It Works

Trainspotter reads your Rails log files and parses the standard Rails log format. A background job (IngestJob) processes new log entries and stores them in a separate SQLite database.

Requests View:

  • HTTP method and path
  • Controller and action
  • Response status (color-coded)
  • Total duration
  • Number of SQL queries and view renders
  • Click to expand and see SQL queries and renders

Sessions View:

  • Groups requests by user session (based on IP + time window)
  • Automatic login/logout detection
  • See all requests made during a session

Trainspotter supports tagged logging (config.log_tags = [:request_id]) for accurate request grouping in multi-threaded environments.

Requirements

  • Rails 8.0+
  • Ruby 3.3+

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/botandrose/trainspotter.

License

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