Revisions
-
mcmire revised this gist
Sep 16, 2011 . 1 changed file with 0 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,16 +3,9 @@ #----------------------------------------------------------------------------------------------- require File.expand_path('../boot', __FILE__) require 'rails/all' Bundler.require(:default, Rails.env) if defined?(Bundler) # Bring in the Railtie that will set Rails' various logger variables to # instances of Logging::Logger instead of Rails' built-in ActiveSupport::BufferedLogger. require File.expand_path('../../lib/my_app/logging-rails', __FILE__) -
mcmire revised this gist
Jan 19, 2011 . 3 changed files with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ #----------------------------------------------------------------------------------------------- # config/application.rb #----------------------------------------------------------------------------------------------- This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ #----------------------------------------------------------------------------------------------- # lib/my_app/logging-rails.rb #----------------------------------------------------------------------------------------------- This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ #----------------------------------------------------------------------------------------------- # config/logging.rb #----------------------------------------------------------------------------------------------- -
mcmire revised this gist
Jan 19, 2011 . 3 changed files with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ # config/application.rb #----------------------------------------------------------------------------------------------- require File.expand_path('../boot', __FILE__) require 'rails/all' This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ # lib/my_app/logging-rails.rb #----------------------------------------------------------------------------------------------- require 'logging' module Logging This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ # config/logging.rb #----------------------------------------------------------------------------------------------- Logging::Rails.configure do |config| Logging.format_as :inspect layout = Logging.layouts.pattern(:pattern => '[%d] %-5l %c : %m\n') -
mcmire created this gist
Jan 19, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ require File.expand_path('../boot', __FILE__) require 'rails/all' # If you have a Gemfile, require the gems listed there, including any gems # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env) if defined?(Bundler) # For debugging purposes require 'pp' # Bring in the Railtie that will set Rails' various logger variables to # instances of Logging::Logger instead of Rails' built-in ActiveSupport::BufferedLogger. require File.expand_path('../../lib/my_app/logging-rails', __FILE__) module MyApp class Application < Rails::Application # ... end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ Logging::Rails.configure do |config| Logging.format_as :inspect layout = Logging.layouts.pattern(:pattern => '[%d] %-5l %c : %m\n') Logging.appenders.stdout('stdout', :auto_flushing => true, :layout => layout ) Logging.appenders.rolling_file('logfile', :filename => config.paths.log.to_a.first, :keep => 7, :age => 'daily', :truncate => false, :auto_flushing => true, :layout => layout ) Logging.logger.root.level = config.log_level Logging.logger.root.appenders = %w[logfile] # Under Phusion Passenger smart spawning, we need to reopen all IO streams # after workers have forked. # # The rolling file appender uses shared file locks to ensure that only one # process will roll the log file. Each process writing to the file must have # its own open file descriptor for flock to function properly. Reopening the # file descriptors afte forking ensure that each worker has a unique file # descriptor. # if defined?(PhusionPassenger) PhusionPassenger.on_event(:starting_worker_process) do |forked| Logging.reopen if forked end end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ require 'logging' module Logging module Rails class << self attr_reader :configuration def configure(&block) @configuration = block end end module ControllerMixin def self.included(base) base.extend(self) end def logger @_logger ||= Logging::Logger[self] end end class Railtie < ::Rails::Railtie initializer "logging.configure_logger", :before => :initialize_logger do |app| file = ::Rails.root.join('config/logging.rb') return unless File.exists?(file) require file Logging::Rails.configuration.call(app.config) end initializer "logging.initialize_logger", :before => :initialize_logger do |app| ::Rails.logger = Logging::Logger[::Rails] end initializer "logging.active_record.logger", :before => "active_record.logger" do |app| ActiveSupport.on_load(:active_record) { ActiveRecord::Base.logger = Logging::Logger[ActiveRecord::Base] } end initializer "logging.action_controller.logger", :before => "action_controller.logger" do ActiveSupport.on_load(:action_controller) { ActionController::Base.logger = Logging::Logger[ActionController::Base] } end initializer "logging.action_mailer.logger", :before => "action_mailer.logger" do ActiveSupport.on_load(:action_mailer) { ActionMailer::Base.logger = Logging::Logger[ActionMailer::Base] } end initializer "logger.active_support.dependencies.logger" do ActiveSupport::Dependencies.logger = Logging::Logger[ActiveSupport::Dependencies] end initializer "logger.initialize_cache", :after => :initialize_cache do ::Rails.cache.logger = Logging::Logger[::Rails.cache] end config.after_initialize do Logging.show_configuration if Logging.logger[::Rails].debug? end end end end