factorial-debugbar 0.3.3

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fd2d186cfa126416c92b232a95c064f20136b8e48f3580499b2080038ec45db7
4
+ data.tar.gz: 9e8fd081244c8492a56b8fb6b9b3741414384e6766ff865cc62eacee04ed6b6e
5
+ SHA512:
6
+ metadata.gz: '012380ab4607bdb372a59c193b853822673691c82033cb21683eff4c403c3ab15c7af3675a8c2bf012d21471f158f6a982122fee724fa777e6dede50063dadbe'
7
+ data.tar.gz: 76d065dd725eb7f70a25f90e462544aa51733543a61e563968e2b5a0253d40bcdae4d24e26e53c284465d7375d8793b7d6dff573245d3a888f3ce89f4aee24ba
data/CHANGELOG.md ADDED
@@ -0,0 +1,68 @@
1
+ # Changelog
2
+
3
+ ## v0.3.3 - 2024-06-15
4
+
5
+ * Allow nonce to be set for content security policies - See [#38](https://github.com/julienbourdeau/debugbar/pull/38)
6
+
7
+ ## v0.3.2 - 2024-05-04
8
+
9
+ * Improved Debug panel (to be in par with Queries panel) - See [#36](https://github.com/julienbourdeau/debugbar/pull/36)
10
+ * Better SQL dialect detection - See [c40e2405](https://github.com/julienbourdeau/debugbar/commit/c40e240524308c7ecf09fecbb548e97c2ef4e8b7)
11
+ * Add timings to SQL queries 🎨 - See [ebf8edcd](https://github.com/julienbourdeau/debugbar/commit/ebf8edcd8598a4a7b490a774a7374d51a3efc6b8)
12
+
13
+ ## v0.3.1 - 2024-05-01
14
+
15
+ * Add `active_record.adapter` config to help frontend format SQL queries - See [#35](https://github.com/julienbourdeau/debugbar/pull/35)
16
+ * Add `minimized` config key to start the debugbar minimized - See [2046b054](https://github.com/julienbourdeau/debugbar/commit/0178443d268d2a740a0d73b4039a03dd)
17
+ * Use `:null_session` to disable forgery protection when using polling - See [#27](https://github.com/julienbourdeau/debugbar/pull/27)
18
+
19
+ ## v0.3.0 - 2024-03-31
20
+
21
+ * Add support for Turbo Drive - See [#25](https://github.com/julienbourdeau/debugbar/pull/25) and [#26](https://github.com/julienbourdeau/debugbar/pull/26)
22
+ * Fix error "undefined method `adapter_name' for ActiveJob:Module" for Rails < 7.1 - See [#24](https://github.com/julienbourdeau/debugbar/pull/24)
23
+ * Limit the number of request to 25, configurable with `maxRequests` option - See [664f2c11](https://github.com/julienbourdeau/debugbar/commit/664f2c11e56f18a7c3e4a9fb83ba5b7e19fbb9a9)
24
+
25
+ ### Breaking changes
26
+
27
+ In order to support Turbo Drive, I had to split the helper into two parts. Before the JavaScript file was loaded,
28
+ directly in the body, but it has to be loaded in the head now.
29
+
30
+ If you were passing configuation t `debugbar_javascript`, you must now pass it to `debugbar_body`.
31
+
32
+ ```diff
33
+ <!DOCTYPE html>
34
+ <html>
35
+ <head>
36
+ ...
37
+ + <%= debugbar_head %>
38
+ </head>
39
+
40
+ <body>
41
+ ...
42
+ - <%= debugbar_javascript %>
43
+ + <%= debugbar_body %>
44
+ </body>
45
+ </html>
46
+ ```
47
+
48
+ ## v0.2.0 - 2024-02-28
49
+
50
+ * Introduce polling in case someone cannot use ActiveCable - See [8b262be7](https://github.com/julienbourdeau/debugbar/commit/8b262be7b644c7b587a6c3348bb02076053a344f)
51
+ * https://debugbar.dev/docs/polling-mode
52
+ * Show more timings information (total time, DB runtime and CPU time) - See [c02531ed](https://github.com/julienbourdeau/debugbar/commit/c02531ed6e9d9c74df11d4d8c30e3fb7bf970852)
53
+ * Move main middleware higher in the chain - See [7ca51c10](https://github.com/julienbourdeau/debugbar/commit/7ca51c10c5999f7ad14a303c92083614551de134)
54
+ * Silence debugbar routes for quieter logs - See [efe491bd](https://github.com/julienbourdeau/debugbar/commit/efe491bde9e0544e5fb891597bb2af47854c1169)
55
+
56
+ ### Breaking changes
57
+
58
+ The frontend configuration was slightly modified. If you customized the prefix for the debugbar routes or the channelName, you must update your config.
59
+ Prefix is at the root, and channelName is nested under the cable key.
60
+
61
+ ```diff
62
+ - <%= debugbar_javascript channelName: "something_else", cable: {prefix: "custom-prefix"} %>
63
+ + <%= debugbar_javascript prefix: "custom-prefix", cable: {channelName: "something_else"} %>
64
+ ```
65
+
66
+ ## v0.1.0 - 2024-02-13
67
+
68
+ * Initial release 🎉
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Julien Bourdeau
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # Debugbar for Rails
2
+
3
+ Find all documentation on [debugbar.dev](https://debugbar.dev/)
4
+
5
+ [![debugbar screesnhot](https://debugbar.dev/assets/screenshots/home.png)](https://debugbar.dev/docs/)
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,26 @@
1
+ module Debugbar
2
+ class DebugbarChannel < ActionCable::Channel::Base
3
+ def subscribed
4
+ stream_from "debugbar_channel"
5
+ end
6
+
7
+ def receive(data)
8
+ if data["clear"]
9
+ RequestBuffer.clear!
10
+ end
11
+
12
+ if data["ids"].present?
13
+ RequestBuffer.remove(data["ids"])
14
+ end
15
+
16
+ Debugbar.connect!
17
+
18
+ data = RequestBuffer.all.map(&:to_h)
19
+ ActionCable.server.broadcast("debugbar_channel", data)
20
+ end
21
+
22
+ def unsubscribed
23
+ Debugbar.disconnect!
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,4 @@
1
+ module Debugbar
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,15 @@
1
+ module Debugbar
2
+ class AssetsController < ApplicationController
3
+ def js
4
+ render file: File.join(Gem.loaded_specs['debugbar'].full_gem_path, 'public', 'debugbar.js'),
5
+ layout: false,
6
+ content_type: 'text/javascript'
7
+ end
8
+
9
+ private
10
+
11
+ def verify_same_origin_request
12
+ true # YOLO
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ module Debugbar
2
+ class PollingController < ApplicationController
3
+ protect_from_forgery with: :null_session
4
+ before_action :cors_set_access_control_headers
5
+
6
+ def poll
7
+ render json: RequestBuffer.all.map(&:to_h)
8
+ end
9
+
10
+ def confirm
11
+ RequestBuffer.remove params[:ids]
12
+ head :ok
13
+ end
14
+
15
+ private
16
+
17
+ def cors_set_access_control_headers
18
+ response.headers['Access-Control-Allow-Origin'] = '*'
19
+ response.headers['Access-Control-Allow-Headers'] = 'Content-Type'
20
+ response.headers['Access-Control-Allow-Methods'] = 'POST, GET'
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,48 @@
1
+ module Debugbar::TagHelpers
2
+ def debugbar_head
3
+ raw <<-HTML
4
+ <script defer src="#{Debugbar.config.prefix}/assets/script"></script>
5
+ HTML
6
+ end
7
+
8
+ def debugbar_body(opt = {})
9
+ opt = ActiveSupport::HashWithIndifferentAccess.new(opt)
10
+
11
+ # See https://github.com/julienbourdeau/debugbar/issues/8
12
+ if !defined?(ActionCable) && opt[:mode].nil?
13
+ opt[:mode] = 'poll'
14
+ end
15
+
16
+ if opt[:active_record].nil?
17
+ opt[:active_record] = { adapter: db_adapter }
18
+ end
19
+
20
+ html = <<-HTML
21
+ <div id="__debugbar" data-turbo-permanent></div>
22
+ HTML
23
+
24
+ html += <<-HTML
25
+ <script type="text/javascript" data-turbo-permanent nonce="#{opt.delete(:nonce)}">
26
+ window._debugbarConfigOptions = #{opt.to_json}
27
+ </script>
28
+ HTML
29
+
30
+ raw html
31
+ end
32
+
33
+ def debugbar_javascript(opt = {})
34
+ errors = [""]
35
+ errors << "debugbar_javascript was removed in 0.3.0."
36
+ errors << "Please use `debugbar_head` inside <head> and `debugbar_body` at the end of <body> instead."
37
+ errors << "It was split to support Turbo Drive."
38
+ errors << "See https://debugbar.dev/changelog/ for more information."
39
+ errors << ""
40
+ raise errors.join("\n")
41
+ end
42
+
43
+ private
44
+
45
+ def db_adapter
46
+ ActiveRecord::Base.connection.adapter_name.downcase
47
+ end
48
+ end
@@ -0,0 +1,5 @@
1
+ module Debugbar
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
data/build_client.sh ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ rm -rf client/dist
4
+ (cd client && npm run build)
5
+ cp client/dist/assets/debugbar-*.js public/debugbar.js
data/build_demo.sh ADDED
@@ -0,0 +1,13 @@
1
+ #!/bin/bash
2
+
3
+ ruby ./build_fixtures.rb
4
+ rm -rf client/dist-demo
5
+ (cd client/ && VITE_DEMO_MODE=true npm run build)
6
+
7
+ if [ -d "../debugbar.dev/source/assets/debugbar" ]; then
8
+ echo
9
+ echo "debugbar.dev found in parent directory"
10
+ echo " -> Copying assets"
11
+ rm -f ../debugbar.dev/source/assets/debugbar/*
12
+ cp ./client/dist-demo/assets/* ../debugbar.dev/source/assets/debugbar/
13
+ fi
data/build_fixtures.rb ADDED
@@ -0,0 +1,32 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ fixtures_dir = File.expand_path('../fixtures/requests', __FILE__)
5
+
6
+ puts "Deleting old fixtures in #{fixtures_dir}"
7
+ Dir.glob("#{fixtures_dir}/*").each { |p| File.delete(p) }
8
+
9
+ Net::HTTP.start('127.0.0.1', 3000) do |http|
10
+ [
11
+ '/post-list',
12
+ '/slow-page',
13
+ '/random',
14
+ '/post/240',
15
+ '/api/jobs?name=refresh&post_id=123',
16
+ '/api/jobs?name=send_email&post_id=123',
17
+ '/api/errors?code=500',
18
+ ].each do |path|
19
+ puts "Requesting #{path}"
20
+ http.request Net::HTTP::Get.new(path)
21
+ sleep 0.5
22
+ end
23
+
24
+ puts "Requesting debugbar data"
25
+ response = http.request Net::HTTP::Get.new('/_debugbar/poll')
26
+ data = JSON.parse(response.body)
27
+ data.each_with_index do |item, idx|
28
+ name = ("%03d" % (idx +1)) + '-' + item['meta']['controller'] + '-' + item['meta']['action']
29
+ File.write("#{fixtures_dir}/#{name}.json", JSON.pretty_generate(item))
30
+ end
31
+ end
32
+
data/build_gem.sh ADDED
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ source build_client.sh
4
+ gem build debugbar.gemspec
data/config/routes.rb ADDED
@@ -0,0 +1,11 @@
1
+ Debugbar::Engine.routes.draw do
2
+ if defined? ActionCable
3
+ mount ActionCable.server => '/cable'
4
+ end
5
+
6
+ get 'poll' => "polling#poll"
7
+ options 'poll/confirm' => "polling#confirm"
8
+ post 'poll/confirm' => "polling#confirm"
9
+
10
+ get 'assets/script' => "assets#js"
11
+ end
data/debugbar.gemspec ADDED
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/debugbar/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'factorial-debugbar'
7
+ spec.version = Debugbar::VERSION
8
+ spec.authors = ['Julien Bourdeau']
9
+ spec.email = ['julien@debugbar.dev']
10
+
11
+ spec.summary = 'Powerful devtools for Ruby on Rails'
12
+ spec.description = 'Get a better understanding of your application performance and behavior (SQL queries, jobs, cache, routes, logs, etc)'
13
+ spec.homepage = 'https://debugbar.dev'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 2.6.0'
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://github.com/julienbourdeau/debugbar'
19
+ spec.metadata['changelog_uri'] = 'https://debugbar.dev/changelog/'
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ files_to_remove = %w[
24
+ bin/ test/ spec/ features/ fixtures/
25
+ client/
26
+ .git .circleci appveyor Gemfile package.json package-lock.json .prettierrc
27
+ ]
28
+
29
+ spec.files = Dir.chdir(__dir__) do
30
+ `git ls-files -z`.split("\x0").reject do |f|
31
+ (File.expand_path(f) == __FILE__) ||
32
+ f.start_with?(*files_to_remove)
33
+ end
34
+ end.push('public/debugbar.js')
35
+
36
+ spec.bindir = 'exe'
37
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
38
+ spec.require_paths = ['lib']
39
+
40
+ spec.add_dependency 'actioncable' # , ">= 7.1.1"
41
+ spec.add_dependency 'rails' # , ">= 7.1.1"
42
+
43
+ # For more information and examples about making a new gem, check out our
44
+ # guide at: https://bundler.io/guides/creating_gem.html
45
+ end
@@ -0,0 +1,34 @@
1
+ module Debugbar
2
+ class MemoryBuffer
3
+ def initialize
4
+ @collection = {}
5
+ end
6
+
7
+ def push(request)
8
+ @collection[request.id] = request
9
+ nil
10
+ end
11
+
12
+ def remove(ids)
13
+ ids = Array.wrap(ids)
14
+ ids.each do |id|
15
+ @collection.delete(id)
16
+ end
17
+ :self
18
+ end
19
+
20
+ def all
21
+ @collection.values
22
+ end
23
+
24
+ def each(&block)
25
+ @collection.each(&block)
26
+ :self
27
+ end
28
+
29
+ def clear!
30
+ @collection = {}
31
+ :self
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,18 @@
1
+ module Debugbar
2
+ class NullBuffer
3
+ def push(_request)
4
+ end
5
+
6
+ def remove(_ids)
7
+ end
8
+
9
+ def all
10
+ end
11
+
12
+ def each
13
+ end
14
+
15
+ def clear!
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ module Debugbar
2
+ class RequestBuffer
3
+ class << self
4
+ def init(adapter)
5
+ @adapter = adapter
6
+ end
7
+
8
+ %w(push each all remove clear!).each do |name|
9
+ define_method(name) do |*args, &block|
10
+ ret = @adapter.send(name, *args, &block)
11
+ ret == :self ? self : ret
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,50 @@
1
+ module Debugbar
2
+ class Config
3
+ attr_accessor :enabled, :prefix, :buffer_adapter, :ignore_request,
4
+ :active_record, :action_controller, :active_job,
5
+ :min_log_level
6
+
7
+ alias_method :enabled?, :enabled
8
+
9
+ def initialize(options = {})
10
+ opt = defaults.merge options
11
+ @enabled = opt[:enabled] && !defined?(Rails::Console)
12
+ @prefix = opt[:prefix]
13
+ @active_record = opt[:active_record]
14
+ @action_controller = opt[:action_controller]
15
+ @active_job = opt[:active_job]
16
+ @min_log_level = opt[:min_log_level]
17
+ @buffer_adapter = opt[:buffer_adapter]
18
+ end
19
+
20
+ def defaults
21
+ {
22
+ enabled: Rails.env.development?,
23
+ prefix: "/_debugbar",
24
+ active_record: true,
25
+ action_controller: true,
26
+ active_job: true,
27
+ min_log_level: -1,
28
+ buffer_adapter: :memory,
29
+ }
30
+ end
31
+
32
+ def ignore_request?(env)
33
+ if ignore_request.is_a? Proc
34
+ ignore_request.call(env)
35
+ else
36
+ [Debugbar.config.prefix, "/assets"].any? { |s| env['PATH_INFO'].start_with? s }
37
+ end
38
+ end
39
+
40
+ def use_logger?
41
+ @enabled && @min_log_level >= 0
42
+ end
43
+
44
+ %w(active_record action_controller active_job).each do |name|
45
+ define_method("#{name}?") do
46
+ @enabled && instance_variable_get("@#{name}")
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Debugbar
4
+ class Current < ActiveSupport::CurrentAttributes
5
+ attribute :request
6
+ attribute :ignore
7
+
8
+ alias_method :ignore?, :ignore
9
+
10
+ def new_request!(request_id)
11
+ self.request = Request.new(request_id)
12
+ end
13
+
14
+ def pop_request!
15
+ request.tap { self.request = nil }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,96 @@
1
+ require_relative 'config'
2
+ require_relative 'middlewares/quiet_routes'
3
+ require_relative 'middlewares/track_current_request'
4
+ require_relative '../../app/helpers/debugbar/tag_helpers'
5
+
6
+ module Debugbar
7
+ class Engine < ::Rails::Engine
8
+ isolate_namespace Debugbar
9
+
10
+ initializer 'debugbar.config' do |app|
11
+ app.config.debugbar = ::Debugbar.config
12
+ end
13
+
14
+ initializer 'debugbar.init' do |app|
15
+ adapter = case(app.config.debugbar.buffer_adapter)
16
+ when :memory
17
+ require_relative 'buffers/memory_buffer'
18
+ MemoryBuffer.new
19
+ when :null
20
+ require_relative 'buffers/null_buffer'
21
+ NullBuffer.new
22
+ else
23
+ throw "Invalid RequestBuffer adapter"
24
+ end
25
+
26
+ Debugbar::RequestBuffer.init(adapter)
27
+ end
28
+
29
+ initializer 'debugbar.helper' do
30
+ ActiveSupport.on_load(:action_controller) do
31
+ ActionController::Base.helper(Debugbar::TagHelpers)
32
+ end
33
+
34
+ ActiveSupport.on_load(:action_view) do
35
+ include Debugbar::TagHelpers
36
+ end
37
+ end
38
+
39
+ initializer 'debugbar.inject_middlewares' do |app|
40
+ next unless Debugbar.config.enabled?
41
+ app.middleware.insert_after ActionDispatch::Executor, Debugbar::TrackCurrentRequest
42
+ app.middleware.insert_after Debugbar::TrackCurrentRequest, Debugbar::QuietRoutes
43
+ end
44
+
45
+ initializer 'debugbar.subscribe' do
46
+ if Debugbar.config.active_record?
47
+ require_relative 'subscribers/active_record'
48
+ subscribe "Debugbar::ActiveRecordEventSubscriber" => "sql.active_record"
49
+ end
50
+
51
+ if Debugbar.config.action_controller?
52
+ require_relative 'subscribers/action_controller'
53
+ subscribe "Debugbar::ActionControllerEventSubscriber" => %w[
54
+ start_processing.action_controller process_action.action_controller
55
+ ]
56
+ end
57
+
58
+ if Debugbar.config.active_job?
59
+ require_relative 'subscribers/active_job'
60
+ subscribe "Debugbar::ActiveJobEventSubscriber" => ["enqueue.active_job", "enqueue_at.active_job"]
61
+ end
62
+
63
+ require_relative 'subscribers/active_support'
64
+ subscribe "Debugbar::ActiveSupportEventSubscriber.cache" => %w(
65
+ cache_read.active_support
66
+ cache_generate.active_support
67
+ cache_fetch_hit.active_support
68
+ cache_write.active_support
69
+ cache_delete.active_support
70
+ cache_exist?.active_support
71
+ )
72
+ end
73
+
74
+ initializer 'debugbar.track_models' do
75
+ next unless Debugbar.config.active_record?
76
+ ActiveSupport.on_load(:active_record) do
77
+ after_initialize do |model|
78
+ Debugbar::Tracker.inc_model(model.class.name)
79
+ end
80
+ end
81
+ end
82
+
83
+ def subscribe(config)
84
+ config.each do |subscriber, event_names|
85
+ event_names = Array.wrap(event_names)
86
+ class_name, class_method_name = subscriber.split('.')
87
+ event_names.each do |name|
88
+ method_name = class_method_name || name.split('.').first
89
+ ActiveSupport::Notifications.subscribe name do |event|
90
+ class_name.constantize.send method_name, event
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,34 @@
1
+ module Debugbar
2
+ class SimpleLogger < ::Logger
3
+ def initialize(min_level= 2)
4
+ @min_level = min_level
5
+ end
6
+
7
+ def add(severity, message = nil, progname = nil)
8
+ # We normally rely on the Tracker to know if the current request is set or nil and log an error to STDOUT,
9
+ # but in this case, it happens so often that the logs are annoying.
10
+ # In ActiveCable, only the first call goes through the Rake middleware, so every following communication
11
+ # doesn't go through TrackCurrentRequest, which initializes the request.
12
+ return if ::Debugbar::Current.request.nil?
13
+
14
+ return if severity < @min_level
15
+
16
+ if message.nil?
17
+ if block_given?
18
+ message = yield
19
+ else
20
+ message = progname
21
+ progname = nil
22
+ end
23
+ end
24
+
25
+ Debugbar::Tracker.add_log({
26
+ time: Time.now.strftime(Debugbar::TIME_FORMAT),
27
+ severity: severity,
28
+ severity_label: SEV_LABEL[severity],
29
+ message: message,
30
+ progname: progname,
31
+ })
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,23 @@
1
+ # This middleware silences the Rails logger for requests to the Debugbar routes.
2
+ # The poll route can be *very* noisy.
3
+ # Rails already does this for the /assets route, see Sprockets::Rails::QuietAssets.
4
+ #
5
+ # @see Sprockets::Rails::QuietAssets
6
+ # @see Rails::Rack::Logger#silence
7
+ #
8
+ module Debugbar
9
+ class QuietRoutes
10
+ def initialize(app)
11
+ @app = app
12
+ @route_regex = %r(\A/{0,2}#{::Debugbar.config.prefix})
13
+ end
14
+
15
+ def call(env)
16
+ if env['PATH_INFO'] =~ @route_regex
17
+ ::Rails.logger.silence { @app.call(env) }
18
+ else
19
+ @app.call(env)
20
+ end
21
+ end
22
+ end
23
+ end