From c8e9225dfb4186ce0f91c772138d95819fc33323 Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Sat, 14 May 2011 13:29:54 -0700 Subject: [PATCH] For the love of god, normal Rails logs in test & development. There's now a setting in app_config.yml, :enable_splunk_logging, which if true outputs godawful machine-readable splunk logs. It's false in test and development, and true elsewhere. --- config/app_config.yml.example | 7 ++++++- config/application.rb | 1 - config/initializers/_splunk_logger.rb | 4 ++++ spec/shared_behaviors/log_override.rb | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config/app_config.yml.example b/config/app_config.yml.example index c22764da9..8d3c1ec47 100644 --- a/config/app_config.yml.example +++ b/config/app_config.yml.example @@ -92,11 +92,16 @@ default: #s3_secret: 'secret' #s3_bucket: 'my_photos' - + # If you want normal Rails logs, set this to false in the appropriate environment. + # It is false by default in development and test. + enable_splunk_logging: true + development: + enable_splunk_logging: false test: pod_url: "http://example.org/" socket_port: 8081 + enable_splunk_logging: false production: diff --git a/config/application.rb b/config/application.rb index 16c16a120..08ae3ba54 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,7 +9,6 @@ require 'rails/all' # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env) if defined?(Bundler) -require File.expand_path('../../lib/log_overrider', __FILE__) require File.expand_path('../../lib/fake', __FILE__) module Diaspora diff --git a/config/initializers/_splunk_logger.rb b/config/initializers/_splunk_logger.rb index b2d45248a..5cb075836 100644 --- a/config/initializers/_splunk_logger.rb +++ b/config/initializers/_splunk_logger.rb @@ -1 +1,5 @@ +if AppConfig[:enable_splunk_logging] + require File.expand_path('../../../lib/log_overrider', __FILE__) +end + Rails.logger.class.send(:include, SplunkLogging) diff --git a/spec/shared_behaviors/log_override.rb b/spec/shared_behaviors/log_override.rb index 96cdd3c09..4a768395f 100644 --- a/spec/shared_behaviors/log_override.rb +++ b/spec/shared_behaviors/log_override.rb @@ -1,3 +1,5 @@ +require File.expand_path('../../../lib/log_overrider', __FILE__) + class FakeLogger attr_accessor :infos attr_accessor :lines