Skip to content
Viames Marino edited this page Apr 28, 2026 · 3 revisions

Pair framework: LogBar

Pair\Helpers\LogBar is Pair’s local request inspector for events, SQL queries, warnings, errors, and request timing.

Main methods

  • getInstance(): LogBar
  • event(string $description, string $type = 'notice', ?string $subtext = null): void
  • render(): string
  • canBeShown(): bool
  • disable(): void

Useful counters:

  • getErrorCount(): int
  • getWarningCount(): int
  • getQueryCount(): int

The legacy event API remains supported:

\Pair\Helpers\LogBar::event('Import started', 'notice');

The database layer uses a structured query event internally so SQL can be grouped safely by fingerprint.

Request inspector

The rendered LogBar includes:

  • Overview diagnostics for slow requests, DB-bound requests, high query counts, duplicate query fingerprints, slow queries, warnings/errors, and memory pressure
  • Timeline waterfall based on request-relative event start and duration
  • Queries view grouped by normalized SQL fingerprint
  • Events view with the chronological event list
  • Vanilla-JS search and filters for text, event type, queries, warnings/errors, and duplicate query groups

The header separates runtime context from performance metrics. The title area shows route/action when available, application environment, active UI framework, the current Bootstrap or Bulma breakpoint when one of those UI frameworks is selected, and a copyable Pair observability correlation ID. The metric row shows total request time, DB time and percentage, query count, peak memory, and warning/error counts.

SQL safety

LogBar is a local debug tool, not a production data export channel.

By default, SQL query previews are normalized and do not render bound values:

SELECT * FROM sessions WHERE id = ? LIMIT ?

Set PAIR_LOGBAR_SHOW_SQL_VALUES=true only for a controlled local debugging session. Even with that opt-in enabled, values are masked when parameter names or nearby column names suggest sensitive data such as tokens, secrets, passwords, authorization headers, cookies, sessions, SIDs, emails, keys, or hashes.

Pair does not add raw SQL parameters to db.query observability spans.

Configuration

Defaults:

  • PAIR_LOGBAR_SLOW_REQUEST_MS=250
  • PAIR_LOGBAR_SLOW_QUERY_MS=20
  • PAIR_LOGBAR_QUERY_BUDGET=30
  • PAIR_LOGBAR_DUPLICATE_QUERY_BUDGET=3
  • PAIR_LOGBAR_MAX_EVENTS=500
  • PAIR_LOGBAR_SHOW_SQL_VALUES=false

Implementation examples

Track slow operation:

\Pair\Helpers\LogBar::event('External API call', 'api', 'provider-x');

Render in template/layout:

echo \Pair\Helpers\LogBar::getInstance()->render();

Notes

  • DB layer automatically writes safe query events to LogBar.
  • Visibility depends on user permissions and options.
  • AJAX LogBar output remains a compact event list for compatibility and follows the same SQL value hiding defaults.

See also: Database, Logger, Application, Observability, Configuration-file.

Clone this wiki locally