Skip to content

Commit

Permalink
Merge pull request #71 from textmaster/active_record_fix
Browse files Browse the repository at this point in the history
don't require ActiveRecord if it's not already available
  • Loading branch information
reidmorrison committed Jul 31, 2018
2 parents 962fae0 + d8470e4 commit 2200c8b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/rails_semantic_logger/engine.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'active_record/log_subscriber'
require 'action_controller/log_subscriber'

module RailsSemanticLogger
Expand Down Expand Up @@ -222,11 +221,15 @@ class Engine < ::Rails::Engine

if config.rails_semantic_logger.semantic
# Active Record
RailsSemanticLogger.swap_subscriber(
::ActiveRecord::LogSubscriber,
RailsSemanticLogger::ActiveRecord::LogSubscriber,
:active_record
)
if defined?(::ActiveRecord)
require 'active_record/log_subscriber'

RailsSemanticLogger.swap_subscriber(
::ActiveRecord::LogSubscriber,
RailsSemanticLogger::ActiveRecord::LogSubscriber,
:active_record
)
end

# Rack
RailsSemanticLogger::Rack::Logger.started_request_log_level = :info if config.rails_semantic_logger.started
Expand Down

0 comments on commit 2200c8b

Please sign in to comment.