File "BasicLoggerFactory.php"
Full Path: /home/siazco/grocery.siazco.se/wp-content/plugins/flexible-shipping-pro/vendor_prefixed/wpdesk/wp-logs/src/BasicLoggerFactory.php
File size: 1.53 KB
MIME-type: text/x-php
Charset: utf-8
<?php
namespace FSProVendor\WPDesk\Logger;
use FSProVendor\Monolog\Handler\HandlerInterface;
use FSProVendor\Monolog\Logger;
use FSProVendor\Monolog\Registry;
/**
* Manages and facilitates creation of logger
*
* @package WPDesk\Logger
*/
class BasicLoggerFactory implements \FSProVendor\WPDesk\Logger\LoggerFactory
{
/** @var string Last created logger name/channel */
private static $lastLoggerChannel;
/**
* Creates logger for plugin
*
* @param string $name The logging channel/name of logger
* @param HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc.
* @param callable[] $processors Optional array of processors
* @return Logger
*/
public function createLogger($name, $handlers = array(), array $processors = array())
{
if (\FSProVendor\Monolog\Registry::hasLogger($name)) {
return \FSProVendor\Monolog\Registry::getInstance($name);
}
self::$lastLoggerChannel = $name;
$logger = new \FSProVendor\Monolog\Logger($name, $handlers, $processors);
\FSProVendor\Monolog\Registry::addLogger($logger);
return $logger;
}
/**
* Returns created Logger by name or last created logger
*
* @param string $name Name of the logger
*
* @return Logger
*/
public function getLogger($name = null)
{
if ($name === null) {
$name = self::$lastLoggerChannel;
}
return \FSProVendor\Monolog\Registry::getInstance($name);
}
}