Skip to content

Extracting Sidekiq logic out of rails_semantic_logger #260

Open
@Drowze

Description

@Drowze

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 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions