Skip to content

Commit 3f8c7f5

Browse files
committed
Allow logger middleware to be customizable, closes #87
1 parent c58fc8f commit 3f8c7f5

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ The following config is available:
5555

5656
* `allow_remote_access` - Tidewave only allows requests from localhost by default, even if your server listens on other interfaces as well. If you trust your network and need to access Tidewave from a different machine, this configuration can be set to `true`
5757

58+
* `logger_middleware` - The logger middleware Tidewave should wrap to silence its own logs
59+
5860
* `preferred_orm` - which ORM to use, either `:active_record` (default) or `:sequel`
5961

6062
* `team` - set your Tidewave Team configuration, such as `config.tidewave.team = { id: "my-company" }`

lib/tidewave/configuration.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module Tidewave
44
class Configuration
5-
attr_accessor :logger, :allow_remote_access, :preferred_orm, :dev, :client_url, :team
5+
attr_accessor :logger, :allow_remote_access, :preferred_orm, :dev, :client_url, :team, :logger_middleware
66

77
def initialize
88
@logger = nil
@@ -11,6 +11,7 @@ def initialize
1111
@dev = false
1212
@client_url = "https://tidewave.ai"
1313
@team = {}
14+
@logger_middleware = nil
1415
end
1516
end
1617
end

lib/tidewave/railtie.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class Railtie < Rails::Railtie
4141
initializer "tidewave.intercept_exceptions" do |app|
4242
# We intercept exceptions from DebugExceptions, format the
4343
# information as text and inject into the exception page html.
44-
4544
ActionDispatch::DebugExceptions.register_interceptor do |request, exception|
4645
request.set_header("tidewave.exception", exception)
4746
end
@@ -51,7 +50,8 @@ class Railtie < Rails::Railtie
5150

5251
initializer "tidewave.logging" do |app|
5352
# Do not pollute user logs with tidewave requests.
54-
app.middleware.insert_before(Rails::Rack::Logger, Tidewave::QuietRequestsMiddleware)
53+
logger_middleware = app.config.tidewave.logger_middleware || Rails::Rack::Logger
54+
app.middleware.insert_before(logger_middleware, Tidewave::QuietRequestsMiddleware)
5555
end
5656
end
5757
end

0 commit comments

Comments
 (0)