Создание логгера

@param string $name Имя логгера (используется также для имени файла)

@return Logger

@version 31.01.2019
@author  Дмитрий Щербаков <atomcms@ya.ru>
491551
static function create($name)
    {
        $logger = new Logger($name);
        $filename = SettingsPath::LOGS . mb_strtolower($name, 'UTF-8') . '.log';
        $handler = new RotatingFileHandler($filename);

        $handler->setFilenameFormat('{date}-{filename}', 'Y/m/d');

        $logger->pushHandler($handler);

        return $logger;
    }
517421
public function name($name) {

		if(false === is_string($name)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($name)), E_USER_ERROR);
		}

		$this -> name = $name;

		return $this;
	}
162981
public function helper($name) {
		if (isset($this->_helpers[$name])) {
			return $this->_helpers[$name];
		}
		list($plugin, $helperClassName) = pluginSplit($name, true);
		$helperClassName = Inflector::camelize($helperClassName) . "ShellHelper";
		App::uses($helperClassName, $plugin . "Console/Helper");
		if (!class_exists($helperClassName)) {
			throw new RuntimeException("Class " . $helperClassName . " not found");
		}
		$helper = new $helperClassName($this->stdout);
		$this->_helpers[$name] = $helper;

		return $helper;
	}
892924
public function getParser($name)
    {
        if (!isset($this->instances[$name])) {
            if (!isset($this->mapping[$name])) {
                return null;
            }
            $class = $this->mapping[$name];
            $this->instances[$name] = new $class();
        }

        return $this->instances[$name];
    }
465915
protected function get($name)
    {
        return $this->channels[$name] ?? with($this->resolve($name), function ($driver) use ($name) {
            return new SMSSender($driver);
        });
    }
37113
public function getPathToLogFile($name = 'm62')
    {
        if (is_null($this->log_path)) {
            $this->log_path = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'logs') . DIRECTORY_SEPARATOR . $name . '.log';
        }
        
        return $this->log_path;
    }
4133
public static function streamHandler($name)
    {
        $suffix = date('Y-m-d-H');
        $date = date('Y-m-d');
        $pathName = str_replace('.', '/', $name);
        $streamHandler = new StreamHandler(storage_path("logs/$date/$pathName/$name-$suffix.log"));
        $streamHandler->setFormatter(new LineFormatter(null, null, true, false));
        return $streamHandler;
    }
795186
public function register($name)
	{
		return $this->addCommand(new Command($name, $this->input, $this->output));
	}
1289243
public static function create($name)
    {
        $logger = new Logger($name);

        $localLogConfig = config('logger.local_log');
        if($localLogConfig['enabled'] && !in_array($name, $localLogConfig['exclude_names'])) {
            $streamHandler = self::streamHandler($name);
            $logger->pushHandler($streamHandler);
        }

        $logstashConfig = config('logger.logstash');
        if($logstashConfig['enabled'] && !in_array($name, $logstashConfig['exclude_names'])){
            $gelfHandler = self::logStashHandler($logstashConfig);
            $logger->pushHandler($gelfHandler);
        }

        $requestId = Request::header('x-request-id');
        $logger->setRequestId($requestId);

        return $logger;
    }
747001
public static function getModifier(string $name)
    {
        if (isset(self::$modifiers[$name])) {
            return self::$modifiers[$name];
        }
        $class = '\\sdopx\\plugin\\' . Utils::toCamel($name) . 'Modifier';
        if (class_exists($class)) {
            self::$modifiers[$name] = new $class();
            return self::$modifiers[$name];
        }
        return null;
    }
279579
public ErrorLogger getLogger(final String name) {
        if (name == null || name.equals("")) return null;
        if (!hasLog(name)) {
            addLog(name);
        }
        return getLog(name);
    }
1132575
public function getTag(string $name)
    {
        $tagFinderOutput = $this->caller
            ->execute(TagCommand::getInstance()->listTags())
            ->getOutputLines(true);

        foreach ($tagFinderOutput as $line) {
            if ($line === $name) {
                return new Tag($this, $name);
            }
        }

        return null;
    }
633532
public function getAppender($name)
    {
        if (!isset($this->_appenders[$name])) {
            return false;
        }

        $appender = $this->_appenders[$name];
        if (is_object($appender)) {
            return $appender;
        } elseif (is_string($appender)) {
            $className = strpos($appender, '\\') !== false ? $appender : 'ManaPHP\Logger\Appender\\' . ucfirst($appender);
            return $this->_appenders[$name] = $this->_di->getShared($className);
        } elseif (is_array($appender)) {
            if (isset($appender['instance'])) {
                return $appender['instance'];
            } else {
                if (isset($appender['level'])) {
                    $appender['level'] = array_search($appender['level'], self::$_levels, true);
                }
                $className = isset($appender['class']) ? $appender['class'] : $name;
                $className = strpos($className, '\\') ? $className : 'ManaPHP\Logger\Appender\\' . ucfirst($className);
                $appender['instance'] = $instance = $this->_di->getInstance($className, $appender);
                $this->_appenders[$name] = $appender;
                return $instance;
            }
        } else {
            throw new MisuseException('');
        }
    }
131305
public static function resolve($name)
    {
        $logger     = $GLOBALS['logger'];
        $app        = $GLOBALS['app'];
        $staticPath = 'public';
        
        if ($app->getConfiguration()->isLocal()) {
            $staticPath = 'views';
        }

        $session    = $app->getSessionManager()->getActiveSession();
        $category   = $session->getAttribute('category');
        $basePath   = '/'.$staticPath.'/resources/'.$category;
        $commonPath = '/'.$staticPath.'/resources/common';

        $searchFolder = '.';
        
        $isUrl = false;

        if(preg_match('/.*\.js$/', $name)) {
            $searchFolder = 'scripts';
        } else if(preg_match('/.*\.css$/', $name)) {
            $searchFolder = 'styles';
        } else if(preg_match('/.*\.(?:jpg|jpeg|gif|png)$/', $name)) {
            $searchFolder = 'images';
        } else {
            $isUrl = true;
            $name  = DIRECTORY_SEPARATOR.$app->getConfiguration()->getApplicationContext().DIRECTORY_SEPARATOR.$name;
        }

        if ($isUrl) {
            return $name;
        }

        if (file_exists(getcwd().$basePath.'/'.$searchFolder.'/'.$name)) {
            return '/'.$app->getConfiguration()->getApplicationContext().$basePath.'/'.$searchFolder.'/'.$name;
        } else if (file_exists(getcwd().$commonPath.'/'.$searchFolder.'/'.$name)) {
            return '/'.$app->getConfiguration()->getApplicationContext().$commonPath.'/'.$searchFolder.'/'.$name;
        }
        return $name;
    }
690082
protected static function createLogger(string $name): LoggerInterface
    {
        $config       = static::$config;
        $loggerConfig = $config[$name];
        $handler      = $loggerConfig['handler']['class'];
        $params       = $loggerConfig['handler']['params'] ?? [];

        array_unshift($params, "{$config['folder']}/{$config['prefix']}.$name.log");

        return (new Logger($name))->pushHandler(new $handler(...$params));
    }
647142
public function getLogger($name = null)
    {
        if (null === $name && !isset($this->loggers['nullLogger'])) {
            $this->createNullLogger();
            $name = 'nullLogger';
        }

        return $this->loggers[$name];
    }
1177356
public Logger getLogger(String name) {
        Logger slf4jLogger = loggerMap.get(name);
        if (slf4jLogger != null) {
            return slf4jLogger;
        } else {
            org.apache.log4j.Logger log4jLogger;
            if (name.equalsIgnoreCase(Logger.ROOT_LOGGER_NAME))
                log4jLogger = LogManager.getRootLogger();
            else
                log4jLogger = LogManager.getLogger(name);

            Logger newInstance = new Log4jLoggerAdapter(log4jLogger);
            Logger oldInstance = loggerMap.putIfAbsent(name, newInstance);
            return oldInstance == null ? newInstance : oldInstance;
        }
    }