Skip to content

Commit

Permalink
middleware-autoset
Browse files Browse the repository at this point in the history
  • Loading branch information
0exp committed Aug 15, 2024
1 parent 1a412a3 commit 491a945
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/lamian/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@ module Lamian
# max number of most recent log lines to store, defaults to 5000
# @attr raven_log_size_limit [Integer]
# size limit when sending lamian log to sentry, defaults to +500_000+
Config = Struct.new(:formatter, :max_log_lines, :raven_log_size_limit) do
# @attr middleware_autoset [BOolean]
# automatically setup a middleware module during rails initialization process
Config = Struct.new(
:formatter,
:max_log_lines,
:raven_log_size_limit,
:middleware_autoset
) do
def initialize
self.formatter = ::Logger::Formatter.new
self.max_log_lines = 5000
self.raven_log_size_limit = 500_000
self.middleware_autoset = true
end
end
end
4 changes: 3 additions & 1 deletion lib/lamian/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class Engine < ::Rails::Engine

initializer "lamian.use_rack_middleware" do |app|
# :nocov:
app.config.middleware.unshift(Lamian::Middleware)
if Lamian.config.middleware_autoset
app.config.middleware.unshift(Lamian::Middleware)
end
# :nocov:
end

Expand Down

0 comments on commit 491a945

Please sign in to comment.