Sha256: 6ec8f3a977400490e3db48526c96b045eeafbc3e0e6feb6361adafe3c8082bf8

Contents?: true

Size: 877 Bytes

Versions: 6

Compression:

Stored size: 877 Bytes

Contents

module RailwayIpc
  class Logger

    attr_reader :logger

    def initialize(logger)
      @logger = logger
    end

    def info(message, statement)
      logger.info("[#{message_header(message)}] #{statement}")
    end

    def warn(message, statement)
      logger.warn("[#{message_header(message)}] #{statement}")
    end

    def debug(message, statement)
      logger.debug("[#{message_header(message)}] #{statement}")
    end

    def error(message, statement)
      logger.error("[#{message_header(message)}] #{statement}")
    end

    def log_exception(e)
      logger.error(e)
    end

    def message_header(message)
      log_statement = "message type: #{message.class}, uuid: #{message.uuid}, correlation_id: #{message.correlation_id}"
      message.respond_to?(:user_uuid) ? "#{log_statement}, user_uuid: #{message.user_uuid}" : log_statement
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
railway-ipc-0.1.7 lib/railway_ipc/logger.rb
railway-ipc-0.1.6 lib/railway_ipc/logger.rb
railway-ipc-0.1.5 lib/railway_ipc/logger.rb
railway-ipc-0.1.4 lib/railway_ipc/logger.rb
railway-ipc-0.1.3 lib/railway_ipc/logger.rb
railway-ipc-0.1.2 lib/railway_ipc/logger.rb