Sha256: b8515f4dbfb1aaf3270d18b8f1d371e259ba7ae005959d0f5f1eca563b24f957

Contents?: true

Size: 676 Bytes

Versions: 3

Compression:

Stored size: 676 Bytes

Contents

# frozen_string_literal: true

# typed: false

# Helper methods added to RestServer
module ServerUtils
  def log(messages)
    if SchemalessRestApi.log_type == :ougai
      log_structured(messages)
    else
      message = messages.values.join(", ")
      SchemalessRestApi.logger.info "#{message}, #{request.request_method} #{request.fullpath}, CorrelationId: #{@request_id}"
    end
  end

  private def log_structured(messages)
    log_msg = {
      method: request.request_method,
      path: request.fullpath,
      correlationId: @request_id
    }
    messages.each do |key, value|
      log_msg[key] = value
    end
    SchemalessRestApi.logger.info(log_msg)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
schemaless_rest_api-0.6.0 lib/schemaless_rest_api/server_utils.rb
schemaless_rest_api-0.5.1 lib/schemaless_rest_api/server_utils.rb
schemaless_rest_api-0.5.0 lib/schemaless_rest_api/server_utils.rb