rails_stdout_logging 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.travis.yml +10 -0
  4. data/Appraisals +15 -0
  5. data/Gemfile +9 -0
  6. data/README.md +59 -2
  7. data/Rakefile +27 -0
  8. data/gemfiles/rails_3.0.x.gemfile +13 -0
  9. data/gemfiles/rails_3.1.x.gemfile +13 -0
  10. data/gemfiles/rails_3.2.x.gemfile +13 -0
  11. data/gemfiles/rails_4.0.x.gemfile +13 -0
  12. data/lib/rails_stdout_logging.rb +0 -2
  13. data/lib/rails_stdout_logging/rails.rb +2 -3
  14. data/lib/rails_stdout_logging/railtie.rb +1 -1
  15. data/lib/rails_stdout_logging/version.rb +1 -1
  16. data/{rails_log_stdout.gemspec → rails_stdout_logging.gemspec} +1 -0
  17. data/test/dummy/Rakefile +7 -0
  18. data/test/dummy/app/controllers/application_controller.rb +3 -0
  19. data/test/dummy/app/controllers/bar_controller.rb +12 -0
  20. data/test/dummy/app/helpers/application_helper.rb +2 -0
  21. data/test/dummy/app/views/bar/index.html.erb +1 -0
  22. data/test/dummy/config.ru +4 -0
  23. data/test/dummy/config/application.rb +45 -0
  24. data/test/dummy/config/boot.rb +10 -0
  25. data/test/dummy/config/database.yml +22 -0
  26. data/test/dummy/config/environment.rb +5 -0
  27. data/test/dummy/config/environments/development.rb +26 -0
  28. data/test/dummy/config/environments/production.rb +49 -0
  29. data/test/dummy/config/environments/test.rb +35 -0
  30. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  31. data/test/dummy/config/initializers/inflections.rb +10 -0
  32. data/test/dummy/config/initializers/mime_types.rb +5 -0
  33. data/test/dummy/config/initializers/secret_token.rb +7 -0
  34. data/test/dummy/config/initializers/session_store.rb +8 -0
  35. data/test/dummy/config/locales/en.yml +9 -0
  36. data/test/dummy/config/locales/es.yml +10 -0
  37. data/test/dummy/config/routes.rb +60 -0
  38. data/test/dummy/public/404.html +26 -0
  39. data/test/dummy/public/422.html +26 -0
  40. data/test/dummy/public/500.html +26 -0
  41. data/test/dummy/public/favicon.ico +0 -0
  42. data/test/dummy/public/javascripts/application.js +2 -0
  43. data/test/dummy/public/javascripts/controls.js +965 -0
  44. data/test/dummy/public/javascripts/dragdrop.js +974 -0
  45. data/test/dummy/public/javascripts/effects.js +1123 -0
  46. data/test/dummy/public/javascripts/prototype.js +6001 -0
  47. data/test/dummy/public/javascripts/rails.js +202 -0
  48. data/test/dummy/public/stylesheets/.gitkeep +0 -0
  49. data/test/dummy/script/rails +6 -0
  50. data/test/integration/controller_logging_test.rb +9 -0
  51. data/test/rails_stdout_logging_test.rb +20 -0
  52. data/test/support/integration_case.rb +6 -0
  53. data/test/test_helper.rb +36 -0
  54. metadata +87 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a4392b1c9b8fbb3f3113e56f1c2bd0ca5dada05
4
- data.tar.gz: 1fba8dd578f13f3a3938c6bc7eb330f3b2648c6b
3
+ metadata.gz: f962b41cfcf24041cc6771adb5e9ac114c9417b4
4
+ data.tar.gz: de22b58d015a3f9fe5f8b8b65e1369fc9cf66ce5
5
5
  SHA512:
6
- metadata.gz: 6d1873e2afc444dc1cab8068d0c2894162c86a2f4c49b16762f4ef266fa93466603db3fa9e6adaae906f29ff8dbeb1c3f86c41cceb44b14f8e954238d6dd6eb6
7
- data.tar.gz: 4906e2de889d805ed5f32dbeeab202527b91db6b59fc5fa2e4a56eddf94430647a9a01662af67bbf4a5e5ecb2d1911352762f78e029a48914a089dc5c5df71d6
6
+ metadata.gz: 3f4827c5113e041ae50ecdacdf8e5428c44b4cbe1be9f40321f1e962610f5f35f5fe1cf20b8befd9180b652d0584b805dd36eaba13a6e84128eaa8a16d34a4ae
7
+ data.tar.gz: 4b55501983ca0569b03dfd171e2778d8ec69025ac33b2614683f78cd0020c9e3faa1b3acba5268c5aee1a79aa1397293913ab3cef01067a1231399aebdd81011
data/.gitignore CHANGED
@@ -15,3 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ *.log
19
+ gemfiles/*.gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+
6
+ gemfile:
7
+ - gemfiles/rails_3.0.x.gemfile
8
+ - gemfiles/rails_3.1.x.gemfile
9
+ - gemfiles/rails_3.2.x.gemfile
10
+ - gemfiles/rails_4.0.x.gemfile
data/Appraisals ADDED
@@ -0,0 +1,15 @@
1
+ appraise "rails-3.0.x" do
2
+ gem "rails", "~> 3.0.0"
3
+ end
4
+
5
+ appraise "rails-3.1.x" do
6
+ gem "rails", "~> 3.1.0"
7
+ end
8
+
9
+ appraise "rails-3.2.x" do
10
+ gem "rails", "~> 3.2.0"
11
+ end
12
+
13
+ appraise "rails-4.0.x" do
14
+ gem "rails", "~> 4.0.0"
15
+ end
data/Gemfile CHANGED
@@ -2,3 +2,12 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rails_stdout_logging.gemspec
4
4
  gemspec
5
+
6
+ gem 'appraisal'
7
+
8
+ gem 'rake'
9
+ gem "capybara"
10
+ gem "launchy"
11
+
12
+ gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
13
+ gem "activerecord-jdbcsqlite3-adapter", '>= 1.3.0.beta', :platform => :jruby
data/README.md CHANGED
@@ -1,4 +1,61 @@
1
- # rails_stdout_logging
1
+ # Rails Stdout Logging
2
+
3
+ Rails gem to configure your app to log to standard out.
4
+
5
+ [![Build Status](https://travis-ci.org/heroku/rails_stdout_logging.png?branch=master)](https://travis-ci.org/heroku/rails_stdout_logging)
6
+
7
+ Supports:
8
+
9
+ - Rails 3
10
+ - Rails 4
11
+
12
+
13
+
14
+ ## Install
15
+
16
+ In your `Gemfile` add:
17
+
18
+ ```
19
+ gem 'rails_stdout_logging'
20
+ ```
21
+
22
+ Then run
23
+
24
+ ```
25
+ $ bundle install`
26
+ ```
27
+
28
+ You also need the `rails_serve_static_assets` gem. You can get both of them together by installing `rails_on_heroku` gem.
29
+
30
+ ## Why is this needed?
31
+
32
+ By default Rails writes its logs to a file which is convenient but only you only have one log file to tail. When you start scaling your app to multiple machines or dynos then finding a single request or failure across multiple files becomes much harder. Storing logs on disk can also take down a server if the hard drive fills up. Because of these limitations: every Rails core member we talked to uses a custom logger to replace Rail's default functionality. By using the `rails_stdout_logging` gem with Heroku, we set the logger for you.
33
+
34
+ The gem `rails_stdout_logging` ensures that your logs will be sent to standard out, from there Heroku sends them to [logplex](https://github.com/heroku/logplex) so you can access them from the command line, `$ heroku logs --tail`, or from enabled addons like [papertrail](https://addons.heroku.com/papertrail). By using Heroku's logplex, you can [treat logs as event streams](http://www.12factor.net/logs).
35
+
36
+ ## Why Didn't I need this before?
37
+
38
+ Why do you need to include this gem in Rails 4 and not Rails 3? Rails4 is getting rid of the concept of plugins. Before libraries were easily distributed as Gems and in the form of Engines, Rails had a folder `vendor/plugins`. Any code you put there would be initialized much like a Gem is today. This was a very simple and easy way to share and use libraries, but it wasn't very maintainable. You could use a library, and make a change locally and then deploy which makes your version incompatible from future versions. Even worse there was no concept of versioning aside from source control, so semantic versioning was out of the question. For these reasons and more Rails3 deprecated plugins. With Rails4 plugins have been removed completely. Why does this affect your app on Heroku?
39
+
40
+ In the past Heroku has used plugins as a safe way to configure your application where code was needed. While we advocate [separating config from code](http://12factor.net), this was the only option if we wanted your apps to work with no changes from you. With Rails3 Heroku will add the asset serving and standardout logging plugins to your app automatically. With Rails4, Heroku needs you to add these libraries to your Gemfile.
41
+
42
+ It is important to note that unlike Gems, plugins do not have a dependency resolution phase like what happens when you run `bundle install`. Heroku does not and will not add anything to your Gemfile on compilation.
43
+
44
+ ## Tests
45
+
46
+ Since we're playing with stdout we need to capture stdout. If you want to use the non captured version use `DEBUG_STDOUT` instead. The `puts` method should still behave as you expect.
47
+
48
+ We're using appraisal to build multiple gemfiles for different versions of Rails.
49
+
50
+ You can run all tests by running
51
+
52
+ ```
53
+ $ bundle exec rake appraisal test
54
+ ```
55
+
56
+
57
+ ## The Future
58
+
59
+ We will be working with Rails and the Rails core team to make future versions of Rails work on Heroku out of the box. Until then you'll need to add this gem to your project.
2
60
 
3
- Configure a Rails 2 or 3 app to log to STDOUT by default
4
61
 
data/Rakefile CHANGED
@@ -1,2 +1,29 @@
1
1
  #!/usr/bin/env rake
2
+ require 'rubygems'
3
+ require 'bundler'
4
+
5
+ begin
6
+ Bundler.setup(:default, :development, :test)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+
2
13
  require "bundler/gem_tasks"
14
+
15
+ require 'rake'
16
+ require 'rdoc/task'
17
+
18
+ require 'rake/testtask'
19
+
20
+ Rake::TestTask.new(:test) do |t|
21
+ t.libs << 'lib'
22
+ t.libs << 'test'
23
+ t.pattern = 'test/**/*_test.rb'
24
+ t.verbose = false
25
+ end
26
+
27
+ task :default => :test
28
+
29
+ require 'appraisal'
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rake"
7
+ gem "capybara"
8
+ gem "launchy"
9
+ gem "sqlite3", :platform=>[:ruby, :mswin, :mingw]
10
+ gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.0.beta", :platform=>:jruby
11
+ gem "rails", "~> 3.0.0"
12
+
13
+ gemspec :path=>"../"
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rake"
7
+ gem "capybara"
8
+ gem "launchy"
9
+ gem "sqlite3", :platform=>[:ruby, :mswin, :mingw]
10
+ gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.0.beta", :platform=>:jruby
11
+ gem "rails", "~> 3.1.0"
12
+
13
+ gemspec :path=>"../"
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rake"
7
+ gem "capybara"
8
+ gem "launchy"
9
+ gem "sqlite3", :platform=>[:ruby, :mswin, :mingw]
10
+ gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.0.beta", :platform=>:jruby
11
+ gem "rails", "~> 3.2.0"
12
+
13
+ gemspec :path=>"../"
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rake"
7
+ gem "capybara"
8
+ gem "launchy"
9
+ gem "sqlite3", :platform=>[:ruby, :mswin, :mingw]
10
+ gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.0.beta", :platform=>:jruby
11
+ gem "rails", "~> 4.0.0"
12
+
13
+ gemspec :path=>"../"
@@ -1,4 +1,2 @@
1
-
2
-
3
1
  require "rails_stdout_logging/version"
4
2
  require "rails_stdout_logging/railtie" if defined?(Rails)
@@ -1,9 +1,8 @@
1
1
  module RailsStdoutLogging
2
2
  class Rails
3
-
4
3
  def self.heroku_stdout_logger
5
- logger = Logger.new(STDOUT)
6
- logger = ActiveSupport::TaggedLogging.new(logger) if defined?(ActiveSupport::TaggedLogging)
4
+ logger = Logger.new(STDOUT)
5
+ logger = ActiveSupport::TaggedLogging.new(logger) if defined?(ActiveSupport::TaggedLogging)
7
6
  logger.level = Logger.const_get(log_level)
8
7
  logger
9
8
  end
@@ -2,7 +2,7 @@ require 'rails_stdout_logging/rails3'
2
2
 
3
3
  module RailsStdoutLogging
4
4
  class Railtie < ::Rails::Railtie
5
- config.after_initialize do
5
+ config.before_initialize do
6
6
  Rails3.set_logger(config)
7
7
  end
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module RailsStdoutLogging
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -13,5 +13,6 @@ Gem::Specification.new do |gem|
13
13
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
14
  gem.name = "rails_stdout_logging"
15
15
  gem.require_paths = ["lib"]
16
+ gem.license = "MIT"
16
17
  gem.version = RailsStdoutLogging::VERSION
17
18
  end
@@ -0,0 +1,7 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+ require 'rake'
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,12 @@
1
+ ## This controller uses includes
2
+
3
+ class BarController < ApplicationController
4
+
5
+ def index
6
+ Rails.logger.info "Logging with Rails.logger" # Printed to STDOUT
7
+ logger.info "Logging with logger" # Not printed to STDOUT
8
+ end
9
+
10
+ def update
11
+ end
12
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1 @@
1
+ Index
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,45 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "active_model/railtie"
4
+ require "active_record/railtie"
5
+ require "action_controller/railtie"
6
+ require "action_view/railtie"
7
+ require "action_mailer/railtie"
8
+
9
+ Bundler.require
10
+ require "rails_stdout_logging"
11
+
12
+ module Dummy
13
+ class Application < Rails::Application
14
+ # Settings in config/environments/* take precedence over those specified here.
15
+ # Application configuration should go into files in config/initializers
16
+ # -- all .rb files in that directory are automatically loaded.
17
+
18
+ # Custom directories with classes and modules you want to be autoloadable.
19
+ # config.autoload_paths += %W(#{config.root}/extras)
20
+
21
+ # Only load the plugins named here, in the order given (default is alphabetical).
22
+ # :all can be used as a placeholder for all plugins not explicitly named.
23
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
24
+
25
+ # Activate observers that should always be running.
26
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
27
+
28
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
29
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
30
+ # config.time_zone = 'Central Time (US & Canada)'
31
+
32
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
33
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
34
+ # config.i18n.default_locale = :de
35
+
36
+ # JavaScript files you want as :defaults (application.js is always included).
37
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
38
+
39
+ # Configure the default encoding used in templates for Ruby 1.9.
40
+ config.encoding = "utf-8"
41
+
42
+ # Configure sensitive parameters which will be filtered from the log file.
43
+ config.filter_parameters += [:password]
44
+ end
45
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,22 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ development:
4
+ adapter: sqlite3
5
+ database: ":memory:"
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ # Warning: The database defined as "test" will be erased and
10
+ # re-generated from your development database when you run "rake".
11
+ # Do not set this db to the same as development or production.
12
+ test:
13
+ adapter: sqlite3
14
+ database: ":memory:"
15
+ pool: 5
16
+ timeout: 5000
17
+
18
+ production:
19
+ adapter: sqlite3
20
+ database: ":memory:"
21
+ pool: 5
22
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,26 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the webserver when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_view.debug_rjs = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Don't care if the mailer can't send
18
+ config.action_mailer.raise_delivery_errors = false
19
+
20
+ # Print deprecation notices to the Rails logger
21
+ config.active_support.deprecation = :log
22
+
23
+ # Only use best-standards-support built into browsers
24
+ config.action_dispatch.best_standards_support = :builtin
25
+ end
26
+
@@ -0,0 +1,49 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The production environment is meant for finished, "live" apps.
5
+ # Code is not reloaded between requests
6
+ config.cache_classes = true
7
+
8
+ # Full error reports are disabled and caching is turned on
9
+ config.consider_all_requests_local = false
10
+ config.action_controller.perform_caching = true
11
+
12
+ # Specifies the header that your server uses for sending files
13
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
14
+
15
+ # For nginx:
16
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17
+
18
+ # If you have no front-end server that supports something like X-Sendfile,
19
+ # just comment this out and Rails will serve the files
20
+
21
+ # See everything in the log (default is :info)
22
+ # config.log_level = :debug
23
+
24
+ # Use a different logger for distributed setups
25
+ # config.logger = SyslogLogger.new
26
+
27
+ # Use a different cache store in production
28
+ # config.cache_store = :mem_cache_store
29
+
30
+ # Disable Rails's static asset server
31
+ # In production, Apache or nginx will already do this
32
+ config.serve_static_assets = false
33
+
34
+ # Enable serving of images, stylesheets, and javascripts from an asset server
35
+ # config.action_controller.asset_host = "http://assets.example.com"
36
+
37
+ # Disable delivery errors, bad email addresses will be ignored
38
+ # config.action_mailer.raise_delivery_errors = false
39
+
40
+ # Enable threaded mode
41
+ # config.threadsafe!
42
+
43
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
44
+ # the I18n.default_locale when a translation can not be found)
45
+ config.i18n.fallbacks = true
46
+
47
+ # Send deprecation notices to registered listeners
48
+ config.active_support.deprecation = :notify
49
+ end