# frozen_string_literal: true require 'lograge' require 'active_support/core_ext/array' module Loggable module Lograge # Custom formatter class that renders logs as ruby objects with just the ecs fields generated by the logger, the # message, and a lograge flag so the ECS logger knows to process this further before rendering class Formatter < ::Lograge::Formatters::KeyValue def call(data) (data[:ecs] || {}).merge(message: super(data), lograge: true) end protected def fields_to_display(data) data.keys.excluding(%i[ecs]) end end end end