diff --git a/cloudflare.loader.php b/cloudflare.loader.php index c5305212..95d5b099 100644 --- a/cloudflare.loader.php +++ b/cloudflare.loader.php @@ -1,6 +1,8 @@ debug = $debug; + } + + /** + * Logs with an arbitrary level. + * + * @param mixed $level + * @param Stringable|string $message + * @param array $context + */ + public function log($level, Stringable|string $message, array $context = []): void + { + error_log(self::PREFIX.' '.strtoupper($level).': '.$message.' '. + (!empty($context) ? print_r($context, true) : '')); + } + + /** + * Detailed debug information. + * + * @param Stringable|string $message + * @param array $context + */ + public function debug(Stringable|string $message, array $context = []): void + { + if ($this->debug) { + $this->log(LogLevel::DEBUG, $message, $context); + } + } +} + +endif;