Skip to content

LogEventSanitizer

Viames Marino edited this page May 5, 2026 · 1 revision

Pair framework: LogEventSanitizer

Pair\Core\LogEventSanitizer prepares log-event payloads before they are stored in LogEvent.

It is used by DatabaseLogWriter and by the LogEvent model lifecycle to keep database log records bounded and safer to inspect.


What it sanitizes

The sanitizer redacts sensitive keys such as:

  • authorization
  • cookie
  • password and passwd
  • secret
  • token
  • apiKey and api_key
  • passphrase
  • csrf
  • session

It also converts unsupported values into safe scalar descriptions and handles Throwable values without serializing the whole object.


Bounds

To avoid oversized log rows, the sanitizer caps:

  • nesting depth;
  • number of array/object entries;
  • scalar string length.

Nested values beyond the configured limits are replaced with compact placeholders.


Server payloads

server() keeps only selected request/server metadata that is useful for diagnostics and avoids raw cookie or authorization values.

The default log record already stores first-class fields such as request method, client IP, user agent, and referer. serverData is an additional bounded diagnostic payload, not a full dump of $_SERVER.


Security note

The sanitizer is a last-mile protection layer. Application code should still avoid logging credentials, tokens, full payment data, or unnecessary personal data in the first place.

See also: DatabaseLogWriter, LogEvent, ErrorLog, Logger.

Clone this wiki locally