PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Infrastructure / Services / Logger / WPLogger.php
ameliabooking / src / Infrastructure / Services / Logger Last commit date
WPLogger.php 5 months ago
WPLogger.php
58 lines
1 <?php
2
3 namespace AmeliaBooking\Infrastructure\Services\Logger;
4
5 use AmeliaBooking\Domain\Services\Logger\LoggerInterface;
6
7 /**
8 * Class WPLogger
9 *
10 * WordPress-based logger implementation using error_log()
11 *
12 * @package AmeliaBooking\Infrastructure\Services\Logger
13 */
14 class WPLogger implements LoggerInterface
15 {
16 private string $prefix;
17
18 public function __construct(string $prefix = 'Amelia')
19 {
20 $this->prefix = $prefix;
21 }
22
23 public function info(string $message, array $context = []): void
24 {
25 $this->log('INFO', $message, $context);
26 }
27
28 public function error(string $message, array $context = []): void
29 {
30 $this->log('ERROR', $message, $context);
31 }
32
33 public function warning(string $message, array $context = []): void
34 {
35 $this->log('WARNING', $message, $context);
36 }
37
38 public function debug(string $message, array $context = []): void
39 {
40 $this->log('DEBUG', $message, $context);
41 }
42
43 /**
44 * Internal method to log messages
45 *
46 * @param string $level
47 * @param string $message
48 * @param array $context
49 *
50 * @return void
51 */
52 private function log(string $level, string $message, array $context = []): void
53 {
54 $contextStr = !empty($context) ? ' | ' . json_encode($context) : '';
55 error_log("[{$this->prefix}] [{$level}] {$message}{$contextStr}");
56 }
57 }
58