Skip to content

Instantly share code, notes, and snippets.

@davidlee
Created March 29, 2010 05:25
Show Gist options
  • Save davidlee/347460 to your computer and use it in GitHub Desktop.
Save davidlee/347460 to your computer and use it in GitHub Desktop.
module MultiLogger
def also_log_to file, &block
@_original_logger, self.logger = logger, ActiveSupport::BufferedLogger.new(file)
yield
self.logger, @_original_logger = logger, nil
end
end
# in application.rb:
include MultiLogger
def also_log_to_another_logger &block
also_log_to '/tmp/another.log', &block
end
around_filter :also_log_to_another_logger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment