Project

biola_logs

0.0
No commit activity in last 3 years
No release in over 3 years
Standardized, opinionated log formatting
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.3
 Project Readme

Biola Logs

A simple gem to standardize log formatting across all our Rails apps using lograge.

Usage

Add the following to your Gemfile

gem 'biola_logs'

Biola Logs doesn't include PID and timestamp, so assuming you want those you'll need to add the following to your environment file(s) (eg. /config/environments/production.rb)

# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new

To log session_id, request_id (or uuid), and host_name you need to add the following custom variables to payload in your controller. The Headers generator will pull these custom variables out and add them to the hash passed to lograge's custom_options config method.

# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
  include BiolaLogs::ControllerExtensions if defined?(BiolaLogs::ControllerExtensions)
end

Generators

Generators inherit from the Base class and should override the to_hash method. Generators.handler merges the returned hash from each generator to populate config.lograge.custom_options in railtie.rb.

License

MIT