Overview

Architecture and design philosophy of WPZylos Logger.

Philosophy

WPZylos Logger provides a PSR-3 compliant logging solution designed specifically for WordPress plugins. It enables structured logging with context support while integrating with WordPress debug tools.

Architecture

┌─────────────────────────────────────────────────────────────┐
|                        Logger                                |
+--───────────────────────────────────────────────────────────┤
|                                                             |
|  ┌─────────────┐  ┌─────────────┐  ┌─────────────────────┐ |
|  | Log Levels  |  |  Min Level  |  |    Formatters       | |
|  | (PSR-3)     |  |  (Filter)   |  |  (Interpolation)    | |
|  +--────┬──────┘  +--────┬──────┘  +--────────┬──────────┘ |
|         |                |                     |            |
|         ▼                ▼                     ▼            |
|  ┌─────────────────────────────────────────────────────┐   |
|  |                   Log Output                         |   |
|  |              (File, error_log)                       |   |
|  +--───────────────────────────────────────────────────┘   |
|                                                             |
+--───────────────────────────────────────────────────────────┘

PSR-3 Log Levels

LevelConstantDescription
EmergencyLogLevel::EMERGENCYSystem is unusable
AlertLogLevel::ALERTImmediate action required
CriticalLogLevel::CRITICALCritical conditions
ErrorLogLevel::ERRORError conditions
WarningLogLevel::WARNINGWarning conditions
NoticeLogLevel::NOTICENormal but significant
InfoLogLevel::INFOInformational messages
DebugLogLevel::DEBUGDebug-level messages

Key Concepts

Structured Logging

Log messages include structured context data:

$logger->info('Order placed', [
    'order_id' => 123,
    'user_id' => 456,
    'total' => 99.99,
]);

Channels

Different output destinations for logs:

  • File — Write to daily log files
  • error_log — PHP error_log function (when WP_DEBUG enabled)

vs Native PHP Logging

Featureerror_logWPZylos Logger
LevelsBad:Good:
ContextBad:Good:
PSR-3Bad:Good:
FormattersBad:Good:
Plugin-awareBad:Good: