Restore logging for cache operations
`AbstractCache` exposes the ability to set a logger. Default behavior automatically passes the logger reference down to the cache, unless a specific cache instance was provided.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
abstract class Mustache_Cache_AbstractCache implements Mustache_Cache
|
||||
{
|
||||
private $logger = null;
|
||||
|
||||
public function getLogger()
|
||||
{
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
public function setLogger($logger = null)
|
||||
{
|
||||
if ($logger !== null && !($logger instanceof Mustache_Logger || is_a($logger, 'Psr\\Log\\LoggerInterface'))) {
|
||||
throw new Mustache_Exception_InvalidArgumentException('Expected an instance of Mustache_Logger or Psr\\Log\\LoggerInterface.');
|
||||
}
|
||||
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
protected function log($level, $message, array $context = array())
|
||||
{
|
||||
if (isset($this->logger)) {
|
||||
$this->logger->log($level, $message, $context);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user