rails_stdout_logging 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9a4392b1c9b8fbb3f3113e56f1c2bd0ca5dada05
4
+ data.tar.gz: 1fba8dd578f13f3a3938c6bc7eb330f3b2648c6b
5
+ SHA512:
6
+ metadata.gz: 6d1873e2afc444dc1cab8068d0c2894162c86a2f4c49b16762f4ef266fa93466603db3fa9e6adaae906f29ff8dbeb1c3f86c41cceb44b14f8e954238d6dd6eb6
7
+ data.tar.gz: 4906e2de889d805ed5f32dbeeab202527b91db6b59fc5fa2e4a56eddf94430647a9a01662af67bbf4a5e5ecb2d1911352762f78e029a48914a089dc5c5df71d6
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails_stdout_logging.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jonathan Dance
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,4 @@
1
+ # rails_stdout_logging
2
+
3
+ Configure a Rails 2 or 3 app to log to STDOUT by default
4
+
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/init.rb ADDED
@@ -0,0 +1,9 @@
1
+ # only applies when used as a plugin
2
+ case Rails::VERSION::MAJOR
3
+ when 2
4
+ require 'rails_stdout_logging/rails2'
5
+ RailsStdoutLogging::Rails2.set_logger
6
+ when 3
7
+ require 'rails_stdout_logging/rails3'
8
+ RailsStdoutLogging::Rails3.set_logger
9
+ end
@@ -0,0 +1,4 @@
1
+
2
+
3
+ require "rails_stdout_logging/version"
4
+ require "rails_stdout_logging/railtie" if defined?(Rails)
@@ -0,0 +1,19 @@
1
+ module RailsStdoutLogging
2
+ class Rails
3
+
4
+ def self.heroku_stdout_logger
5
+ logger = Logger.new(STDOUT)
6
+ logger = ActiveSupport::TaggedLogging.new(logger) if defined?(ActiveSupport::TaggedLogging)
7
+ logger.level = Logger.const_get(log_level)
8
+ logger
9
+ end
10
+
11
+ def self.log_level
12
+ ([ENV['LOG_LEVEL'].to_s.upcase, "INFO"] & %w[DEBUG INFO WARN ERROR FATAL UNKNOWN]).compact.first
13
+ end
14
+
15
+ def self.set_logger
16
+ STDOUT.sync = true
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,47 @@
1
+ require 'rails_stdout_logging/rails'
2
+
3
+ module RailsStdoutLogging
4
+ class Rails2 < Rails
5
+
6
+ def self.set_logger
7
+ super
8
+ redefine_rails_logger!
9
+ classes.each do |klass_name|
10
+ begin
11
+ klass = constantize(klass_name)
12
+ klass.logger = ::Rails.logger
13
+ rescue NameError => exception
14
+ puts "WARNING: #{exception.message}"
15
+ end
16
+ end
17
+ end
18
+
19
+ def redefine_rails_logger!
20
+ class << ::Rails
21
+ def memoized_heroku_logger
22
+ @logger ||= self.heroku_stdout_logger
23
+ end
24
+ alias_method :rails_default_logger, :logger
25
+ alias_method :logger, :memoized_heroku_logger
26
+ end
27
+ end
28
+
29
+ def self.classes
30
+ %w(
31
+ ActiveSupport::Dependencies
32
+ ActiveRecord::Base
33
+ ActionController::Base
34
+ ActionMailer::Base
35
+ ActionView::Base
36
+ ActiveResource::Base
37
+ )
38
+ end
39
+
40
+ def self.constantize(klass_name)
41
+ klass_name.split("::").inject(Object) { |parent, child| parent.const_get(child) }
42
+ rescue NameError
43
+ raise NameError, "Unable to find #{klass_name}"
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,10 @@
1
+ require 'rails_stdout_logging/rails'
2
+
3
+ module RailsStdoutLogging
4
+ class Rails3 < Rails
5
+ def self.set_logger(config)
6
+ super()
7
+ ::Rails.logger = config.logger = heroku_stdout_logger
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ require 'rails_stdout_logging/rails3'
2
+
3
+ module RailsStdoutLogging
4
+ class Railtie < ::Rails::Railtie
5
+ config.after_initialize do
6
+ Rails3.set_logger(config)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module RailsStdoutLogging
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/rails_stdout_logging/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["David Dollar", "Jonathan Dance", "Richard Schneeman"]
6
+ gem.email = ["david@heroku.com", "jd@heroku.com", "richard@heroku.com"]
7
+ gem.description = %q{Sets Rails to log to stdout}
8
+ gem.summary = %q{Overrides Rails' built in logger to send all logs to stdout}
9
+ gem.homepage = "https://github.com/heroku/rails_stdout_logging"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "rails_stdout_logging"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = RailsStdoutLogging::VERSION
17
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_stdout_logging
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - David Dollar
8
+ - Jonathan Dance
9
+ - Richard Schneeman
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-06-12 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: Sets Rails to log to stdout
16
+ email:
17
+ - david@heroku.com
18
+ - jd@heroku.com
19
+ - richard@heroku.com
20
+ executables: []
21
+ extensions: []
22
+ extra_rdoc_files: []
23
+ files:
24
+ - .gitignore
25
+ - Gemfile
26
+ - LICENSE
27
+ - README.md
28
+ - Rakefile
29
+ - init.rb
30
+ - lib/rails_stdout_logging.rb
31
+ - lib/rails_stdout_logging/rails.rb
32
+ - lib/rails_stdout_logging/rails2.rb
33
+ - lib/rails_stdout_logging/rails3.rb
34
+ - lib/rails_stdout_logging/railtie.rb
35
+ - lib/rails_stdout_logging/version.rb
36
+ - rails_log_stdout.gemspec
37
+ homepage: https://github.com/heroku/rails_stdout_logging
38
+ licenses: []
39
+ metadata: {}
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project:
56
+ rubygems_version: 2.0.2
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: Overrides Rails' built in logger to send all logs to stdout
60
+ test_files: []