Skip to content

Logger: use local (Pacific) time for log filenames and entry timestamps instead of UTC #6

Description

@mrtwebdesign

Problem

Hypercart_Logger writes both the log filename date and the entry timestamp in UTC, with a hardcoded UTC label. For a team almost entirely in one timezone, this makes logs awkward to read and causes a confusing mismatch (the filesystem mtime is local while the filename/content date is UTC — e.g. a file modified at 5pm Pacific is named hypercart-2026-05-30.log).

Where (includes/class-hypercart-logger.php)

  • Entry timestampHypercart_Time::utc_format( 'Y-m-d H:i:s' ) (line ~173) plus a hardcoded UTC label in the format string (line ~188): '[%s UTC] %s %s: %s'
  • Filename dateHypercart_Time::utc_format( 'Y-m-d', $timestamp ) in get_log_file() (line ~362)
  • Cleanup cutoff — also uses utc_format() (line ~618), so date-based retention should move with the same change

Desired

Filenames and entry timestamps in Pacific time/date (auto-handling PST/PDT), and the UTC label updated to reflect the actual zone (e.g. PDT/PST via the T format, or the offset).

Example: [2026-05-29 17:00:49 PDT] query_guard WARNING: ... in a file named hypercart-2026-05-29.log.

Implementation options (pick one)

  1. Force Pacific, filterable (recommended) — default new DateTimeZone('America/Los_Angeles'), exposed via a hypercart_log_timezone filter. Consistent on every site regardless of WP settings; overridable per-site.
  2. Follow WP site timezone — switch the logger from utc_format() to the existing site-timezone Hypercart_Time::format() (wp_date() / wp_timezone()). Most WP-idiomatic, but only yields Pacific where Settings → General is set to Los Angeles.
  3. Hardcode Pacific, no filter — simplest; always Pacific, no escape hatch.

Hypercart_Time already distinguishes utc_format() (forced UTC) from format() (site timezone), so the plumbing exists.

Notes / impact

  • This is a shared logging library — the change affects every Hypercart plugin that logs (Server Monitor, Performance Monitor, QueryGuard fallback, etc.).
  • Daily file rotation boundary moves from UTC midnight to Pacific midnight. Existing UTC-named files will coexist harmlessly.
  • Keep storage/DB timestamps (now(), mysql_utc(), iso8601()) in UTC — this change is for the human-facing log files only.

Surfaced while validating the QueryGuard logging bridge (queryguard-plugin #7).

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions