2016-10-19 09:57:06 -04:00
|
|
|
<?php declare(strict_types=1);
|
2016-09-06 17:03:43 -04:00
|
|
|
/**
|
|
|
|
* Banker
|
|
|
|
*
|
|
|
|
* A Caching library implementing psr/cache
|
|
|
|
*
|
2018-11-15 16:38:36 -05:00
|
|
|
* PHP version 7.1
|
2016-09-06 17:03:43 -04:00
|
|
|
*
|
|
|
|
* @package Banker
|
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
2018-11-15 16:38:36 -05:00
|
|
|
* @copyright 2016 - 2018 Timothy J. Warren
|
2016-09-06 17:03:43 -04:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
2018-11-15 16:38:36 -05:00
|
|
|
* @version 2.0.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;
|
|
|
|
}
|
|
|
|
}
|