rails_semantic_logger icon indicating copy to clipboard operation
rails_semantic_logger copied to clipboard

Extracting Sidekiq logic out of rails_semantic_logger

Open Drowze opened this issue 9 months ago • 0 comments
trafficstars

Hello @reidmorrison 👋

I've been recently working in a non-rails project that makes use of Sidekiq and I'd love to integrate SemanticLogger there. From what I can see however, it seems that there's quite a bit of logic to add proper support for Sidekiq - and it's all within rails_semantic_logger codebase.

What do you think of extracting the Sidekiq related code up to semantic_logger or, perhaps, to a new dedicated gem (e.g.: sidekiq_semantic_logger)? Regardless of where the code might move, rails_semantic_logger could still automatically require it and patch Sidekiq logger so I don't think this would be a breaking change - plus it could make development towards Sidekiq development a bit easier to maintain.

From what I see there wouldn't be many changes involved, only:

  1. Move these to their new destination (semantic_logger or sidekiq_semantic_logger):
    • lib/rails_semantic_logger/extensions/sidekiq/sidekiq.rb
    • lib/rails_semantic_logger/sidekiq/defaults.rb
    • lib/rails_semantic_logger/sidekiq/job_logger.rb
    • lib/rails_semantic_logger/sidekiq/loggable.rb
    • the whole sidekiq code block in the rails engine to a new patcher file, e.g.:
    module SidekiqSemanticLogger
      module Patcher
        def self.patch!
          ::Sidekiq.configure_client do |config|
            config.logger = ::SemanticLogger[::Sidekiq]
    # ... and so on
    
  2. Update the rails engine to load the new patcher file and patch Sidekiq logger if the ::Sidekiq constant is defined.

Let me know your thoughts! I can definitely help if that sounds like a welcome change 😄

Drowze avatar Feb 18 '25 20:02 Drowze