2016-10-19 09:57:06 -04:00
|
|
|
<?php declare(strict_types=1);
|
2016-09-06 17:03:43 -04:00
|
|
|
/**
|
|
|
|
* Banker
|
|
|
|
*
|
2020-05-07 19:00:38 -04:00
|
|
|
* A Caching library implementing psr/cache (PSR 6) and psr/simple-cache (PSR 16)
|
2016-09-06 17:03:43 -04:00
|
|
|
*
|
2020-05-07 19:00:38 -04:00
|
|
|
* PHP version 7.4
|
2016-09-06 17:03:43 -04:00
|
|
|
*
|
|
|
|
* @package Banker
|
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
2020-05-07 19:00:38 -04:00
|
|
|
* @copyright 2016 - 2020 Timothy J. Warren
|
2016-09-06 17:03:43 -04:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
2020-05-08 12:30:43 -04:00
|
|
|
* @version 3.1.0
|
2016-09-06 17:03:43 -04:00
|
|
|
* @link https://git.timshomepage.net/timw4mail/banker
|
|
|
|
*/
|
|
|
|
namespace Aviat\Banker;
|
|
|
|
|
2016-10-19 09:57:06 -04:00
|
|
|
use Psr\Log\{
|
|
|
|
LoggerAwareTrait,
|
|
|
|
LoggerInterface,
|
|
|
|
LogLevel,
|
|
|
|
NullLogger
|
|
|
|
};
|
2016-09-06 17:03:43 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Trait for keeping track of logger objects
|
|
|
|
*/
|
|
|
|
trait LoggerTrait {
|
2016-10-19 09:57:06 -04:00
|
|
|
|
|
|
|
use LoggerAwareTrait;
|
|
|
|
|
2016-09-06 17:03:43 -04:00
|
|
|
/**
|
2016-10-19 09:57:06 -04:00
|
|
|
* Return the existing logger instance or
|
2016-09-06 17:03:43 -04:00
|
|
|
* a NullLogger, if no instance set
|
|
|
|
*
|
|
|
|
* @return LoggerInterface
|
|
|
|
*/
|
2018-11-15 16:37:50 -05:00
|
|
|
protected function getLogger(): LoggerInterface
|
2016-09-06 17:03:43 -04:00
|
|
|
{
|
|
|
|
if ($this->logger === NULL)
|
|
|
|
{
|
|
|
|
$this->logger = new NullLogger();
|
|
|
|
}
|
|
|
|
return $this->logger;
|
|
|
|
}
|
2016-10-19 09:57:06 -04:00
|
|
|
|
2016-09-06 17:03:43 -04:00
|
|
|
/**
|
|
|
|
* Set a logger to keep track of errors
|
|
|
|
*
|
|
|
|
* @param LoggerInterface $logger
|
|
|
|
* @return self
|
|
|
|
*/
|
2018-11-15 16:37:50 -05:00
|
|
|
public function setLogger(LoggerInterface $logger): self
|
2016-09-06 17:03:43 -04:00
|
|
|
{
|
|
|
|
$this->logger = $logger;
|
2016-10-19 09:57:06 -04:00
|
|
|
|
2016-09-06 17:03:43 -04:00
|
|
|
// Set the logger for the current driver too
|
|
|
|
if (isset($this->driver))
|
|
|
|
{
|
|
|
|
$this->driver->setLogger($logger);
|
|
|
|
}
|
2016-10-19 09:57:06 -04:00
|
|
|
|
2016-09-06 17:03:43 -04:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|