Skip to content

Commit

Permalink
Turn off verbose_logging by default and updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmorrison committed Jan 14, 2025
1 parent df249ea commit 02bbbce
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,9 @@ You could replace our logger if you want different output:
Rails.application.config.twirp.logger = Rack::CommonLogger
```

Additionally, you can log the Twirp response object to help with debugging:
Additionally, you can log the full Twirp response object to help with debugging:

```ruby
# Defaults to true if your log_level is :debug
Rails.application.config.twirp.verbose_logging = true
```

Expand Down
5 changes: 3 additions & 2 deletions lib/twirp/rails/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class Configuration
# Logger to use for Twirp requests. Defaults to Rails.logger
attr_accessor :logger

# Whether to log Twirp responses. Defaults to true if log level is :debug
# Whether to log full Twirp responses. Can be useful for debugging, but can expose sensitive data.
# Defauts to false
# Example:
# Twirp Response: <Twirp::Example::Haberdasher::Hat: inches: 24, color: "Tan", name: "Pork Pie">
attr_accessor :verbose_logging
Expand All @@ -34,7 +35,7 @@ def initialize
@endpoint = "/twirp"
@load_paths = ["lib"]
@logger = Logger
@verbose_logging = nil
@verbose_logging = false
@middleware = []
@service_hooks = {}
end
Expand Down
2 changes: 0 additions & 2 deletions lib/twirp/rails/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class Engine < ::Rails::Engine

# Set up logging
app.config.middleware.use app.config.twirp.logger, ::Rails.logger
app.config.twirp.verbose_logging = ::Rails.logger.level == ::Logger::DEBUG if app.config.twirp.verbose_logging.nil?

app.config.twirp.middleware.each do |middleware|
app.config.middleware.use middleware
end
Expand Down
2 changes: 2 additions & 0 deletions spec/rails_app/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
module RailsApp
class Application < Rails::Application
config.root = File.expand_path("../../", __FILE__)

config.twirp.verbose_logging = true
end
end

0 comments on commit 02bbbce

Please sign in to comment.