Sha256: 067309306c2d14468dfee85ef7d1a0828e6a12b937387e6c9ae62c7c5bbcd3c8

Contents?: true

Size: 868 Bytes

Versions: 4

Compression:

Stored size: 868 Bytes

Contents

require "mongo/monitoring/command_log_subscriber"

module Mongo
  class Monitoring
    class CommandLogSubscriber
      include SemanticLogger::Loggable
      logger.name = "Mongo"

      undef :started
      def started(event)
        @event_command = event.command
      end

      undef :succeeded
      def succeeded(event)
        logger.debug(message:  prefix(event),
                     duration: (event.duration * 1000),
                     payload:  @event_command)
      end

      undef :failed
      def failed(event)
        logger.debug(message:  "#{prefix(event)} Failed: #{event.message}",
                     duration: (event.duration * 1000),
                     payload:  @event_command)
      end

      undef :prefix
      def prefix(event)
        "#{event.address} | #{event.database_name}.#{event.command_name}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rocketjob-6.3.1 lib/rocket_job/extensions/mongo/logging.rb
rocketjob-6.3.0 lib/rocket_job/extensions/mongo/logging.rb
rocketjob-6.2.0 lib/rocket_job/extensions/mongo/logging.rb
rocketjob-6.1.1 lib/rocket_job/extensions/mongo/logging.rb