rails_stdout_logging 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +19 -0
- data/Appraisals +8 -0
- data/README.md +23 -5
- data/gemfiles/rails_3.0.x.gemfile +3 -3
- data/gemfiles/rails_3.1.x.gemfile +3 -3
- data/gemfiles/rails_3.2.x.gemfile +3 -3
- data/gemfiles/rails_4.0.x.gemfile +3 -3
- data/gemfiles/rails_4.1.x.gemfile +13 -0
- data/gemfiles/rails_4.2.x.gemfile +13 -0
- data/lib/rails_stdout_logging/rails.rb +6 -2
- data/lib/rails_stdout_logging/version.rb +1 -1
- data/rails_stdout_logging.gemspec +2 -0
- data/test/dummy/app/controllers/bar_controller.rb +4 -1
- data/test/integration/controller_logging_test.rb +1 -0
- metadata +64 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be1a47033482eade4227658e44e3f7f097abb38c
|
4
|
+
data.tar.gz: 65ac765fdfeb550bfc257d36007f57a9ae3a6c21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56aaaef2ceb5f1044124fd9cfed5c5051ea98be798ae6eb98f01932149de02034a3a6244ca23bf0d1dd8f0ad4e149ede1ba110280a03735410d0baa1c9778d57
|
7
|
+
data.tar.gz: 8e7473ee615475a633cf5b1e846fb6783b75568bbc671c7334064c82a8486c0961c8313908eb4922b8eafcb96eed8a261cdb370876ec30a1d3cfcff656429e78
|
data/.travis.yml
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
+
- 2.2
|
4
|
+
- 2.1
|
3
5
|
- 2.0.0
|
4
6
|
- 1.9.3
|
5
7
|
|
@@ -8,3 +10,20 @@ gemfile:
|
|
8
10
|
- gemfiles/rails_3.1.x.gemfile
|
9
11
|
- gemfiles/rails_3.2.x.gemfile
|
10
12
|
- gemfiles/rails_4.0.x.gemfile
|
13
|
+
- gemfiles/rails_4.1.x.gemfile
|
14
|
+
- gemfiles/rails_4.2.x.gemfile
|
15
|
+
|
16
|
+
matrix:
|
17
|
+
exclude:
|
18
|
+
- rvm: 2.1
|
19
|
+
gemfile: gemfiles/rails_3.0.x.gemfile
|
20
|
+
- rvm: 2.1
|
21
|
+
gemfile: gemfiles/rails_3.1.x.gemfile
|
22
|
+
- rvm: 2.1
|
23
|
+
gemfile: gemfiles/rails_3.2.x.gemfile
|
24
|
+
- rvm: 2.2
|
25
|
+
gemfile: gemfiles/rails_3.0.x.gemfile
|
26
|
+
- rvm: 2.2
|
27
|
+
gemfile: gemfiles/rails_3.1.x.gemfile
|
28
|
+
- rvm: 2.2
|
29
|
+
gemfile: gemfiles/rails_3.2.x.gemfile
|
data/Appraisals
CHANGED
data/README.md
CHANGED
@@ -22,18 +22,19 @@ gem 'rails_stdout_logging'
|
|
22
22
|
Then run
|
23
23
|
|
24
24
|
```
|
25
|
-
$ bundle install
|
25
|
+
$ bundle install
|
26
26
|
```
|
27
27
|
|
28
|
-
You also need the `rails_serve_static_assets` gem.
|
28
|
+
You also need the [`rails_serve_static_assets` gem](https://github.com/heroku/rails_serve_static_assets).
|
29
|
+
You can get both of them together by installing the [`rails_12factor` gem](https://github.com/heroku/rails_12factor).
|
29
30
|
|
30
31
|
## Why is this needed?
|
31
32
|
|
32
|
-
By default Rails writes its logs to a file which is convenient
|
33
|
+
By default Rails writes its logs to a file, which is convenient because you only have one log file to tail. When you start scaling your app to multiple machines or dynos, it becomes much harder to find a single request or failure as they're spread across multiple files. 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 Rails' default functionality. By using the `rails_stdout_logging` gem with Heroku, we set the logger for you.
|
33
34
|
|
34
|
-
The gem `rails_stdout_logging` ensures that your logs will be sent to standard out
|
35
|
+
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 like `$ 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
|
|
36
|
-
## Why
|
37
|
+
## Why didn't I need this before?
|
37
38
|
|
38
39
|
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
|
|
@@ -41,6 +42,23 @@ In the past Heroku has used plugins as a safe way to configure your application
|
|
41
42
|
|
42
43
|
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
|
|
45
|
+
|
46
|
+
## Set log level
|
47
|
+
|
48
|
+
On Heroku you can set your log level by using the `LOG_LEVEL` environment variable
|
49
|
+
|
50
|
+
```sh
|
51
|
+
$ heroku config:set LOG_LEVEL=DEBUG
|
52
|
+
```
|
53
|
+
|
54
|
+
Valid values include `DEBUG`, `INFO`, `WARN`, `ERROR`, and `FATAL`. Alternatively you can set this value in your environment config:
|
55
|
+
|
56
|
+
```
|
57
|
+
config.log_level = :debug
|
58
|
+
```
|
59
|
+
|
60
|
+
If both are set `LOG_LEVEL` will take precedence.
|
61
|
+
|
44
62
|
## Tests
|
45
63
|
|
46
64
|
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.
|
@@ -6,8 +6,8 @@ gem "appraisal"
|
|
6
6
|
gem "rake"
|
7
7
|
gem "capybara"
|
8
8
|
gem "launchy"
|
9
|
-
gem "sqlite3", :platform=>[:ruby, :mswin, :mingw]
|
10
|
-
gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.0.beta", :platform
|
9
|
+
gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
|
10
|
+
gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.0.beta", :platform => :jruby
|
11
11
|
gem "rails", "~> 3.0.0"
|
12
12
|
|
13
|
-
gemspec :path=>"../"
|
13
|
+
gemspec :path => "../"
|
@@ -6,8 +6,8 @@ gem "appraisal"
|
|
6
6
|
gem "rake"
|
7
7
|
gem "capybara"
|
8
8
|
gem "launchy"
|
9
|
-
gem "sqlite3", :platform=>[:ruby, :mswin, :mingw]
|
10
|
-
gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.0.beta", :platform
|
9
|
+
gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
|
10
|
+
gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.0.beta", :platform => :jruby
|
11
11
|
gem "rails", "~> 3.1.0"
|
12
12
|
|
13
|
-
gemspec :path=>"../"
|
13
|
+
gemspec :path => "../"
|
@@ -6,8 +6,8 @@ gem "appraisal"
|
|
6
6
|
gem "rake"
|
7
7
|
gem "capybara"
|
8
8
|
gem "launchy"
|
9
|
-
gem "sqlite3", :platform=>[:ruby, :mswin, :mingw]
|
10
|
-
gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.0.beta", :platform
|
9
|
+
gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
|
10
|
+
gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.0.beta", :platform => :jruby
|
11
11
|
gem "rails", "~> 3.2.0"
|
12
12
|
|
13
|
-
gemspec :path=>"../"
|
13
|
+
gemspec :path => "../"
|
@@ -6,8 +6,8 @@ gem "appraisal"
|
|
6
6
|
gem "rake"
|
7
7
|
gem "capybara"
|
8
8
|
gem "launchy"
|
9
|
-
gem "sqlite3", :platform=>[:ruby, :mswin, :mingw]
|
10
|
-
gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.0.beta", :platform
|
9
|
+
gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
|
10
|
+
gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.0.beta", :platform => :jruby
|
11
11
|
gem "rails", "~> 4.0.0"
|
12
12
|
|
13
|
-
gemspec :path=>"../"
|
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.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", "~> 4.2.0"
|
12
|
+
|
13
|
+
gemspec :path => "../"
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module RailsStdoutLogging
|
2
|
+
class StdoutLogger < ::Logger
|
3
|
+
include ::LoggerSilence if defined?(::LoggerSilence)
|
4
|
+
end
|
5
|
+
|
2
6
|
class Rails
|
3
7
|
def self.heroku_stdout_logger
|
4
|
-
logger =
|
8
|
+
logger = StdoutLogger.new(STDOUT)
|
5
9
|
logger = ActiveSupport::TaggedLogging.new(logger) if defined?(ActiveSupport::TaggedLogging)
|
6
|
-
logger.level =
|
10
|
+
logger.level = StdoutLogger.const_get(log_level)
|
7
11
|
logger
|
8
12
|
end
|
9
13
|
|
@@ -7,11 +7,13 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.description = %q{Sets Rails to log to stdout}
|
8
8
|
gem.summary = %q{Overrides Rails' built in logger to send all logs to stdout}
|
9
9
|
gem.homepage = "https://github.com/heroku/rails_stdout_logging"
|
10
|
+
gem.license = 'MIT'
|
10
11
|
|
11
12
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
13
|
gem.files = `git ls-files`.split("\n")
|
13
14
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
15
|
gem.name = "rails_stdout_logging"
|
15
16
|
gem.require_paths = ["lib"]
|
17
|
+
gem.add_development_dependency "test-unit", "~> 3"
|
16
18
|
gem.version = RailsStdoutLogging::VERSION
|
17
19
|
end
|
@@ -1,10 +1,13 @@
|
|
1
1
|
## This controller uses includes
|
2
2
|
|
3
3
|
class BarController < ApplicationController
|
4
|
-
|
5
4
|
def index
|
6
5
|
Rails.logger.info "Logging with Rails.logger" # Printed to STDOUT
|
7
6
|
logger.info "Logging with logger" # Not printed to STDOUT
|
7
|
+
|
8
|
+
Rails.logger.silence {
|
9
|
+
Rails.logger.info "This should not be logged!"
|
10
|
+
}
|
8
11
|
end
|
9
12
|
|
10
13
|
def update
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_stdout_logging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Dollar
|
@@ -10,8 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
14
|
-
dependencies:
|
13
|
+
date: 2015-08-20 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: test-unit
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '3'
|
15
29
|
description: Sets Rails to log to stdout
|
16
30
|
email:
|
17
31
|
- david@heroku.com
|
@@ -21,8 +35,8 @@ executables: []
|
|
21
35
|
extensions: []
|
22
36
|
extra_rdoc_files: []
|
23
37
|
files:
|
24
|
-
- .gitignore
|
25
|
-
- .travis.yml
|
38
|
+
- ".gitignore"
|
39
|
+
- ".travis.yml"
|
26
40
|
- Appraisals
|
27
41
|
- Gemfile
|
28
42
|
- LICENSE
|
@@ -32,6 +46,8 @@ files:
|
|
32
46
|
- gemfiles/rails_3.1.x.gemfile
|
33
47
|
- gemfiles/rails_3.2.x.gemfile
|
34
48
|
- gemfiles/rails_4.0.x.gemfile
|
49
|
+
- gemfiles/rails_4.1.x.gemfile
|
50
|
+
- gemfiles/rails_4.2.x.gemfile
|
35
51
|
- init.rb
|
36
52
|
- lib/rails_stdout_logging.rb
|
37
53
|
- lib/rails_stdout_logging/rails.rb
|
@@ -78,7 +94,8 @@ files:
|
|
78
94
|
- test/support/integration_case.rb
|
79
95
|
- test/test_helper.rb
|
80
96
|
homepage: https://github.com/heroku/rails_stdout_logging
|
81
|
-
licenses:
|
97
|
+
licenses:
|
98
|
+
- MIT
|
82
99
|
metadata: {}
|
83
100
|
post_install_message:
|
84
101
|
rdoc_options: []
|
@@ -86,18 +103,55 @@ require_paths:
|
|
86
103
|
- lib
|
87
104
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
105
|
requirements:
|
89
|
-
- -
|
106
|
+
- - ">="
|
90
107
|
- !ruby/object:Gem::Version
|
91
108
|
version: '0'
|
92
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
110
|
requirements:
|
94
|
-
- -
|
111
|
+
- - ">="
|
95
112
|
- !ruby/object:Gem::Version
|
96
113
|
version: '0'
|
97
114
|
requirements: []
|
98
115
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.
|
116
|
+
rubygems_version: 2.4.5
|
100
117
|
signing_key:
|
101
118
|
specification_version: 4
|
102
119
|
summary: Overrides Rails' built in logger to send all logs to stdout
|
103
|
-
test_files:
|
120
|
+
test_files:
|
121
|
+
- test/dummy/Rakefile
|
122
|
+
- test/dummy/app/controllers/application_controller.rb
|
123
|
+
- test/dummy/app/controllers/bar_controller.rb
|
124
|
+
- test/dummy/app/helpers/application_helper.rb
|
125
|
+
- test/dummy/app/views/bar/index.html.erb
|
126
|
+
- test/dummy/config.ru
|
127
|
+
- test/dummy/config/application.rb
|
128
|
+
- test/dummy/config/boot.rb
|
129
|
+
- test/dummy/config/database.yml
|
130
|
+
- test/dummy/config/environment.rb
|
131
|
+
- test/dummy/config/environments/development.rb
|
132
|
+
- test/dummy/config/environments/production.rb
|
133
|
+
- test/dummy/config/environments/test.rb
|
134
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
135
|
+
- test/dummy/config/initializers/inflections.rb
|
136
|
+
- test/dummy/config/initializers/mime_types.rb
|
137
|
+
- test/dummy/config/initializers/secret_token.rb
|
138
|
+
- test/dummy/config/initializers/session_store.rb
|
139
|
+
- test/dummy/config/locales/en.yml
|
140
|
+
- test/dummy/config/locales/es.yml
|
141
|
+
- test/dummy/config/routes.rb
|
142
|
+
- test/dummy/public/404.html
|
143
|
+
- test/dummy/public/422.html
|
144
|
+
- test/dummy/public/500.html
|
145
|
+
- test/dummy/public/favicon.ico
|
146
|
+
- test/dummy/public/javascripts/application.js
|
147
|
+
- test/dummy/public/javascripts/controls.js
|
148
|
+
- test/dummy/public/javascripts/dragdrop.js
|
149
|
+
- test/dummy/public/javascripts/effects.js
|
150
|
+
- test/dummy/public/javascripts/prototype.js
|
151
|
+
- test/dummy/public/javascripts/rails.js
|
152
|
+
- test/dummy/public/stylesheets/.gitkeep
|
153
|
+
- test/dummy/script/rails
|
154
|
+
- test/integration/controller_logging_test.rb
|
155
|
+
- test/rails_stdout_logging_test.rb
|
156
|
+
- test/support/integration_case.rb
|
157
|
+
- test/test_helper.rb
|