| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Loggers; |
| 4 |
|
| 5 |
use YoastSEO_Vendor\Psr\Log\LoggerInterface; |
| 6 |
use YoastSEO_Vendor\Psr\Log\LoggerTrait; |
| 7 |
use YoastSEO_Vendor\Psr\Log\NullLogger; |
| 8 |
|
| 9 |
/** |
| 10 |
* Our logger class. |
| 11 |
*/ |
| 12 |
class Logger implements LoggerInterface { |
| 13 |
|
| 14 |
use LoggerTrait; |
| 15 |
|
| 16 |
/** |
| 17 |
* The logger object. |
| 18 |
* |
| 19 |
* @var LoggerInterface |
| 20 |
*/ |
| 21 |
protected $wrapped_logger; |
| 22 |
|
| 23 |
/** |
| 24 |
* Logger constructor. |
| 25 |
*/ |
| 26 |
public function __construct() { |
| 27 |
$this->wrapped_logger = new NullLogger(); |
| 28 |
|
| 29 |
/** |
| 30 |
* Gives the possibility to set override the logger interface. |
| 31 |
* |
| 32 |
* @param LoggerInterface $logger Instance of NullLogger. |
| 33 |
* |
| 34 |
* @return LoggerInterface The logger object. |
| 35 |
*/ |
| 36 |
$this->wrapped_logger = \apply_filters( 'wpseo_logger', $this->wrapped_logger ); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Logs with an arbitrary level. |
| 41 |
* |
| 42 |
* @param mixed $level The log level. |
| 43 |
* @param string $message The log message. |
| 44 |
* @param array $context The log context. |
| 45 |
* |
| 46 |
* @return void |
| 47 |
*/ |
| 48 |
public function log( $level, $message, array $context = [] ) { |
| 49 |
$this->wrapped_logger->log( $level, $message, $context ); |
| 50 |
} |
| 51 |
} |
| 52 |
|