Project

supalog

0.0
No release in over 3 years
A drop-in Rails logger that buffers log entries and flushes them in batches to the Supalog ingest API via a background thread.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

LogcastSh

Gem Version License: MIT

Ship your Rails logs to logcast.sh with zero external dependencies.

LogcastSh is a drop-in Rails logger that buffers log entries in memory and flushes them in batches to the logcast.sh ingest API via a background thread. Your existing Rails logging continues to work as normal — LogcastSh simply taps into it.

Installation

Add this line to your application's Gemfile:

gem "logcast-sh"

Then execute:

bundle install

Or install it yourself:

gem install logcast-sh

Quick Start

  1. Get your API key from logcast.sh.

  2. Create an initializer:

# config/initializers/logcast.rb
LogcastSh.configure do |config|
  config.api_key = ENV["LOGCAST_API_KEY"]
  config.enabled = Rails.env.production?
end

That's it. Your Rails logs now flow to logcast.sh automatically — no other code changes needed.

Configuration

Option Default Description
api_key nil Required. Your logcast.sh project API key.
url "https://www.logcast.sh" logcast.sh ingest endpoint.
flush_interval 5 Seconds between background flushes.
batch_size 100 Max entries buffered before an immediate flush.
enabled true Enable or disable log shipping.
LogcastSh.configure do |config|
  config.api_key        = ENV["LOGCAST_SH_API_KEY"]
  config.flush_interval = 5                          # seconds, default
  config.batch_size     = 100                        # default
  config.enabled        = true                         # default
end

Per-Environment Usage

Use enabled to control which environments ship logs:

LogcastSh.configure do |config|
  config.api_key = ENV["LOGCAST_SH_API_KEY"]
  config.enabled = Rails.env.production? || Rails.env.staging?
end

When enabled is false, no background thread is started and log entries are silently discarded.

How It Works

  1. Intercepts — Wraps Rails.logger to capture every log call.
  2. Buffers — Stores entries in a thread-safe in-memory array.
  3. Flushes — A background thread sends batches to the logcast.sh API every flush_interval seconds, or immediately when batch_size is reached.
  4. Passes through — All logs still go to the original Rails logger, so your existing output (console, file, etc.) is unaffected.
  5. Shuts down gracefully — Remaining buffered logs are flushed on process exit via at_exit.

LogcastSh never raises exceptions that could crash your application. Transport errors are silently logged to STDERR.

Requirements

  • Ruby >= 3.0
  • Rails (auto-configures via Railtie)
  • Zero external dependencies — uses only Ruby stdlib (net/http, json, uri)

Development

# Run the test suite
bundle exec rspec

# Build the gem locally
bundle exec rake build

# Install the gem locally
bundle exec rake install

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.