Commit ba50715c authored by Doug Barrett's avatar Doug Barrett 🔴
Browse files

refactor(logging): Extract format_data method from JsonLogger

Extract the data formatting logic into a separate `format_data` method
that can be overridden by prepended modules. This enables the upcoming
FieldValidator to intercept and inspect log data without modifying the
core logging flow.

The extracted method:
- Receives severity, timestamp, progname, and message
- Returns the formatted data hash
- Is called by `call` before JSON serialization

No functional changes to logging behavior.
parent 2435b0cd
Loading
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -38,6 +38,12 @@ module Labkit
      end

      def format_message(severity, timestamp, progname, message)
        data = format_data(severity, timestamp, progname, message)

        dump_json(data) << "\n"
      end

      def format_data(severity, timestamp, progname, message)
        data = default_attributes
        data[:severity] = severity
        data[:time] = timestamp.utc.iso8601(3)
@@ -57,7 +63,7 @@ module Labkit
          data.merge!(message)
        end

        dump_json(data) << "\n"
        data
      end

      private