wfarr-ciunas 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README +16 -0
  2. data/ciunas.gemspec +10 -0
  3. data/lib/ciunas.rb +1 -0
  4. data/lib/ciunas/logger.rb +31 -0
  5. metadata +51 -0
data/README ADDED
@@ -0,0 +1,16 @@
1
+ = Ciúnas - rack middleware that silences the rails logger for specific paths
2
+
3
+ This code was originally written by Dennis Reimann, I've simply packaged it as
4
+ a gem. See his blog post for some background info:
5
+ http://dennisreimann.de/blog/silencing-the-rails-log-on-a-per-action-basis/
6
+
7
+ == Usage
8
+
9
+ Either modify config/application.rb or create an initializer that swaps the
10
+ default rails/rack logger middleware for the Ciúnas logger, and specify paths
11
+ for which logging should be silenced using an array of strings and/or regexs.
12
+
13
+ MyApplication::Application.config.middleware.swap (
14
+ Rails::Rack::Logger, Ciunas::Logger,
15
+ :silenced => ["/noisy/action.json", /service_check.*/]
16
+ )
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+ Gem::Specification.new do |s|
3
+ s.name = "wfarr-ciunas"
4
+ s.version = "0.0.3"
5
+ s.summary = "Ciúnas - rack middleware that silences the rails/rack logger for specific actions"
6
+ s.authors = ["Dennis Reimann", "Mark Woods"]
7
+ s.description = "Ciúnas is just a packaged up and slightly tweaked version of the silenceable logger code by Dennis Reimann. See Dennis's blog post for more info: http://dennisreimann.de/blog/silencing-the-rails-log-on-a-per-action-basis/"
8
+ s.homepage = "https://github.com/thickpaddy/ciunas"
9
+ s.files = `git ls-files`.split("\n")
10
+ end
@@ -0,0 +1 @@
1
+ require 'ciunas/logger'
@@ -0,0 +1,31 @@
1
+ module Ciunas
2
+ class Logger < Rails::Rack::Logger
3
+ def initialize(app, opts = {})
4
+ @app = app
5
+ @opts = opts
6
+ @opts[:silenced] ||= []
7
+ end
8
+
9
+ def call(env)
10
+ if env['X-SILENCE-LOGGER'] || @opts[:silenced].any? {|m| m === env['PATH_INFO'] }
11
+ begin
12
+ # temporarily set the rails log level to error
13
+ old_logger_level, Rails.logger.level = Rails.logger.level, tmp_log_level
14
+ @app.call(env)
15
+ ensure
16
+ Rails.logger.level = old_logger_level
17
+ end
18
+ else
19
+ super(env)
20
+ end
21
+ end
22
+
23
+ def tmp_log_level
24
+ if defined?(ActiveSupport::BufferedLogger::Severity::ERROR)
25
+ ActiveSupport::BufferedLogger::Severity::ERROR
26
+ else
27
+ ActiveSupport::Logger::Severity::ERROR
28
+ end
29
+ end
30
+ end
31
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wfarr-ciunas
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dennis Reimann
9
+ - Mark Woods
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-05-21 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: ! 'Ciúnas is just a packaged up and slightly tweaked version of the silenceable
16
+ logger code by Dennis Reimann. See Dennis''s blog post for more info: http://dennisreimann.de/blog/silencing-the-rails-log-on-a-per-action-basis/'
17
+ email:
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - README
23
+ - ciunas.gemspec
24
+ - lib/ciunas.rb
25
+ - lib/ciunas/logger.rb
26
+ homepage: https://github.com/thickpaddy/ciunas
27
+ licenses: []
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 1.8.23
47
+ signing_key:
48
+ specification_version: 3
49
+ summary: Ciúnas - rack middleware that silences the rails/rack logger for specific
50
+ actions
51
+ test_files: []