default services conflit ?
This commit is contained in:
15
old.vendor/consolidation/log/.editorconfig
Normal file
15
old.vendor/consolidation/log/.editorconfig
Normal file
@@ -0,0 +1,15 @@
|
||||
# This file is for unifying the coding style for different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[**.php]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
171
old.vendor/consolidation/log/.github/workflows/ci.yml
vendored
Normal file
171
old.vendor/consolidation/log/.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
# From https://github.com/sebastianbergmann/phpunit/blob/20ab19d3aed56fccf9569cd33c6cd0baab0ec272/.github/workflows/ci.yml
|
||||
# (With many modifications)
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
name: CI
|
||||
|
||||
jobs:
|
||||
coding-guidelines:
|
||||
name: Coding Guidelines
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.4
|
||||
coverage: none
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --no-ansi --no-interaction --no-progress
|
||||
|
||||
- name: Run phpcs
|
||||
run: composer cs
|
||||
|
||||
- name: Run linter
|
||||
run: composer lint
|
||||
|
||||
backward-compatibility:
|
||||
name: Backward Compatibility
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Fetch tags
|
||||
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
|
||||
|
||||
- name: Install PHP with extensions
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.4
|
||||
coverage: none
|
||||
extensions: intl
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --no-ansi --no-interaction --no-progress
|
||||
|
||||
- name: Install roave/backward-compatibility-check
|
||||
run: |
|
||||
mkdir -p tools
|
||||
composer --working-dir=tools require roave/backward-compatibility-check:^5
|
||||
|
||||
- name: Run roave/backward-compatibility-check
|
||||
run: ./tools/vendor/bin/roave-backward-compatibility-check --from=2.0.1
|
||||
|
||||
tests:
|
||||
name: Tests
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
env:
|
||||
PHP_EXTENSIONS: dom, json, libxml, mbstring, pdo_sqlite, soap, xml, xmlwriter
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
|
||||
php-version:
|
||||
- "7.4"
|
||||
|
||||
php-ini-values:
|
||||
- assert.exception=1, zend.assertions=1
|
||||
|
||||
dependencies:
|
||||
- locked
|
||||
|
||||
codecov:
|
||||
- false
|
||||
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
php-version: "7.1"
|
||||
dependencies: lowest
|
||||
|
||||
- os: ubuntu-latest
|
||||
php-version: "7.4"
|
||||
dependencies: lowest
|
||||
|
||||
- os: ubuntu-latest
|
||||
php-version: "8.0"
|
||||
dependencies: highest
|
||||
codecov: true
|
||||
php-ini-values: assert.exception=1, zend.assertions=1, opcache.enable=1, opcache.enable_cli=1, opcache.optimization_level=-1, opcache.jit_buffer_size=4096M, opcache.jit=1205
|
||||
|
||||
- os: ubuntu-latest
|
||||
php-version: "8.1"
|
||||
dependencies: highest
|
||||
codecov: true
|
||||
php-ini-values: assert.exception=1, zend.assertions=1, opcache.enable=1, opcache.enable_cli=1, opcache.optimization_level=-1, opcache.jit_buffer_size=4096M, opcache.jit=1205
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install PHP with extensions
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-version }}
|
||||
coverage: pcov
|
||||
extensions: ${{ env.PHP_EXTENSIONS }}
|
||||
ini-values: ${{ matrix.php-ini-values }}
|
||||
|
||||
- name: Determine composer cache directory on Linux
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
|
||||
|
||||
- name: Determine composer cache directory on Windows
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: Add-Content -Path $ENV:GITHUB_ENV -Value "COMPOSER_CACHE_DIR=~\AppData\Local\Composer"
|
||||
|
||||
- name: Cache dependencies installed with composer
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ${{ env.COMPOSER_CACHE_DIR }}
|
||||
key: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
|
||||
restore-keys: |
|
||||
php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
|
||||
|
||||
- name: Make sure composer.json is valid before we start modifyig it
|
||||
run: composer validate
|
||||
|
||||
- name: Clear platform php configuration in case we need to update phpunit
|
||||
run: composer config --unset platform.php
|
||||
|
||||
- name: Update phpunit if dependencies are locked in case phpunit version in lock file is not compatible
|
||||
if: matrix.dependencies == 'locked'
|
||||
run: |
|
||||
composer install --no-ansi --no-interaction --no-progress
|
||||
composer update --no-ansi --no-interaction --no-progress phpunit/phpunit --with-all-dependencies
|
||||
|
||||
- name: Install lowest dependencies with composer
|
||||
if: matrix.dependencies == 'lowest'
|
||||
run: composer update --no-ansi --no-interaction --no-progress --prefer-lowest
|
||||
|
||||
- name: Install highest dependencies with composer
|
||||
if: matrix.dependencies == 'highest'
|
||||
run: composer update --no-ansi --no-interaction --no-progress
|
||||
|
||||
- name: Run tests with phpunit
|
||||
run: composer unit
|
||||
|
||||
- name: Publish code coverage to Codecov
|
||||
if: matrix.codecov == true
|
||||
run: bash <(curl -s https://codecov.io/bash)
|
5
old.vendor/consolidation/log/.gitignore
vendored
Normal file
5
old.vendor/consolidation/log/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
.DS_Store
|
||||
vendor
|
||||
build
|
||||
dependencies/*/vendor
|
||||
.phpunit.result.cache
|
63
old.vendor/consolidation/log/CHANGELOG.md
Normal file
63
old.vendor/consolidation/log/CHANGELOG.md
Normal file
@@ -0,0 +1,63 @@
|
||||
# Change Log
|
||||
|
||||
### 2.1.1: 2022-02-23:
|
||||
|
||||
- psr/log ^2
|
||||
|
||||
### 2.1.0: 2022-01-29:
|
||||
|
||||
- SettableOutputStreamInterface
|
||||
|
||||
### 2.0.4: 2021-12-30:
|
||||
|
||||
- Symfony 6
|
||||
|
||||
### 2.0.3: 2021-12-29
|
||||
|
||||
- PHP 8.1
|
||||
|
||||
### 2.0.2: 2020-12-10:
|
||||
|
||||
- PHP 8
|
||||
|
||||
### 2.0.1: 2020-5-27:
|
||||
|
||||
- Use symfony5 in tests. Fix erroneous branch alias and minimum php versions in composer.json. (#16)
|
||||
|
||||
### 2.0.0: 2020-2-6:
|
||||
|
||||
- Test with PHP 7.4. Remove support for old versions of PHP.
|
||||
|
||||
### 1.1.1: 2019-1-1
|
||||
|
||||
- Allow logger manager to manage a global style for loggers (#12)
|
||||
|
||||
### 1.1.0: 2018-12-29
|
||||
|
||||
- Add a logger manager (#11)
|
||||
- Update to Composer Test Scenarios 3 (#10)
|
||||
|
||||
### 1.0.6: 2018-05-25
|
||||
|
||||
- Use g1a/composer-test-scenarios (#9)
|
||||
|
||||
### 1.0.5: 2017-11-28
|
||||
|
||||
- Test Symfony version 2, 3 and 4 with different versions of php. (#5)
|
||||
|
||||
### 1.0.4: 2017-11-18
|
||||
|
||||
- Support for Symfony 4 by Tobias Nyholm (#4)
|
||||
|
||||
### 1.0.3: 2016-03-23
|
||||
|
||||
- Split up the log() method a bit.
|
||||
- Run code sniffer prior to running tests to ensure PSR-2 compliance.
|
||||
|
||||
### 1.0.2: 2016-03-22
|
||||
|
||||
- Remove unused components accidentally left in composer.json.
|
||||
|
||||
### 1.0.1: 2016-03-19
|
||||
|
||||
- Add a license file.
|
25
old.vendor/consolidation/log/CONTRIBUTING.md
Normal file
25
old.vendor/consolidation/log/CONTRIBUTING.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Contributing to Consolidation
|
||||
|
||||
Thank you for your interest in contributing to the Consolidation effort! Consolidation aims to provide reusable, loosely-coupled components useful for building command-line tools. Consolidation is built on top of Symfony Console, but aims to separate the tool from the implementation details of Symfony.
|
||||
|
||||
Here are some of the guidelines you should follow to make the most of your efforts:
|
||||
|
||||
## Code Style Guidelines
|
||||
|
||||
Consolidation adheres to the [PSR-2 Coding Style Guide](http://www.php-fig.org/psr/psr-2/) for PHP code.
|
||||
|
||||
## Pull Request Guidelines
|
||||
|
||||
Every pull request is run through:
|
||||
|
||||
- phpcs -n --standard=PSR2 src
|
||||
- phpunit
|
||||
- [Scrutinizer](https://scrutinizer-ci.com/g/consolidation-org/log/)
|
||||
|
||||
It is easy to run the unit tests and code sniffer locally; simply ensure that `./vendor/bin` is in your `$PATH`, cd to the root of the project directory, and run `phpcs` and `phpunit` as shown above. To automatically fix coding standard errors, run:
|
||||
|
||||
- phpcbf --standard=PSR2 src
|
||||
|
||||
After submitting a pull request, please examine the Scrutinizer report. It is not required to fix all Scrutinizer issues; you may ignore recommendations that you disagree with. The spacing patches produced by Scrutinizer do not conform to PSR2 standards, and therefore should never be applied. DocBlock patches may be applied at your discression. Things that Scrutinizer identifies as a bug nearly always needs to be addressed.
|
||||
|
||||
Pull requests must pass phpcs and phpunit in order to be merged; ideally, new functionality will also include new unit tests.
|
19
old.vendor/consolidation/log/LICENSE
Normal file
19
old.vendor/consolidation/log/LICENSE
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2016-2020 Consolidation Org Developers
|
||||
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
DEPENDENCY LICENSES:
|
||||
|
||||
Name Version License
|
||||
psr/container 1.0.0 MIT
|
||||
psr/log 1.1.3 MIT
|
||||
symfony/console v4.4.9 MIT
|
||||
symfony/polyfill-mbstring v1.17.0 MIT
|
||||
symfony/polyfill-php73 v1.17.0 MIT
|
||||
symfony/polyfill-php80 v1.17.0 MIT
|
||||
symfony/service-contracts v1.1.8 MIT
|
45
old.vendor/consolidation/log/README.md
Normal file
45
old.vendor/consolidation/log/README.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# Consolidation\Log
|
||||
|
||||
Improved [PSR-3](http://www.php-fig.org/psr/psr-3/) [Psr\Log](https://github.com/php-fig/log) logger based on Symfony Console components.
|
||||
|
||||
[](https://travis-ci.org/consolidation/log)
|
||||
[](https://scrutinizer-ci.com/g/consolidation/log/?branch=master)
|
||||
[](https://codecov.io/gh/consolidation/log)
|
||||
[](https://packagist.org/packages/consolidation/log)
|
||||
|
||||
## Component Status
|
||||
|
||||
In use in [Robo](https://github.com/Codegyre/Robo).
|
||||
|
||||
## Motivation
|
||||
|
||||
Consolidation\Log provides a PSR-3 compatible logger that provides styled log output to the standard error (stderr) stream. By default, styling is provided by the SymfonyStyle class from the Symfony Console component; however, alternative stylers may be provided if desired.
|
||||
|
||||
## Usage
|
||||
```
|
||||
$logger = new \Consolidation\Log\Logger($output);
|
||||
$logger->setLogOutputStyler(new LogOutputStyler()); // optional
|
||||
$logger->warning('The file {name} does not exist.', ['name' => $filename]);
|
||||
```
|
||||
String interpolation -- that is, the substitution of replacements, such as `{name}` in the example above, is not required by PSR-3, and is not implemented by default in the Psr\Log project. However, it is recommended by PRS-3, and is often done, e.g. in the Symfony Console logger.
|
||||
|
||||
Consolidation\Log supports string interpolation.
|
||||
|
||||
A logger manager can be used to delegate all log messages to one or more loggers.
|
||||
```
|
||||
$logger = new \Consolidation\Log\LoggerManager();
|
||||
$logger->add('default', new \Consolidation\Log\Logger($output));
|
||||
```
|
||||
This is useful if, for example, you need to inject a logger into application objects early (e.g. into a dependency injection container), but the output object to log to will not be available until later.
|
||||
|
||||
## Comparison to Existing Solutions
|
||||
|
||||
Many Symfony Console compoenents use SymfonyStyle to format their output messages. This helper class has methods named things like `success` and `warning`, making it seem like a natural choice for reporting status.
|
||||
|
||||
However, in practice it is much more convenient to use an actual Psr-3 logger for logging. Doing this allows a Symfony Console component to call an external library that may not need to depend on Symfony Style. Having the Psr\Log\LoggerInterface serve as the only shared IO-related interface in common between the console tool and the libraries it depends on promots loose coupling, allowing said libraries to be re-used in other contexts which may wish to log in different ways.
|
||||
|
||||
Symfony Console provides the ConsoleLogger to fill this need; however, ConsoleLogger does not provide any facility for styling output, leaving SymfonyStyle as the preferred logging mechanism for style-conscienscious console coders.
|
||||
|
||||
Consolidation\Log provides the benefits of both classes, allowing for code that both behaved technically correctly (redirecting to stderr) without sacrificing on style.
|
||||
|
||||
Monolog also provides a full-featured Console logger that might be applicable for some use cases.
|
58
old.vendor/consolidation/log/composer.json
Normal file
58
old.vendor/consolidation/log/composer.json
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "consolidation/log",
|
||||
"description": "Improved Psr-3 / Psr\\Log logger based on Symfony Console components.",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Greg Anderson",
|
||||
"email": "greg.1.anderson@greenknowe.org"
|
||||
}
|
||||
],
|
||||
"autoload":{
|
||||
"psr-4":{
|
||||
"Consolidation\\Log\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Consolidation\\TestUtils\\": "tests/src"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1.3",
|
||||
"psr/log": "^1 || ^2",
|
||||
"symfony/console": "^4 || ^5 || ^6"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": ">=7.5.20",
|
||||
"squizlabs/php_codesniffer": "^3",
|
||||
"yoast/phpunit-polyfills": "^0.2.0"
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"scripts": {
|
||||
"cs": "phpcs -n --standard=PSR2 src",
|
||||
"cbf": "phpcbf -n --standard=PSR2 src",
|
||||
"unit": "phpunit --colors=always",
|
||||
"lint": [
|
||||
"find src -name '*.php' -print0 | xargs -0 -n1 php -l",
|
||||
"find tests/src -name '*.php' -print0 | xargs -0 -n1 php -l"
|
||||
],
|
||||
"test": [
|
||||
"@lint",
|
||||
"@unit",
|
||||
"@cs"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "2.x-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true,
|
||||
"platform": {
|
||||
"php": "7.2.28"
|
||||
}
|
||||
}
|
||||
}
|
15
old.vendor/consolidation/log/phpunit.xml.dist
Normal file
15
old.vendor/consolidation/log/phpunit.xml.dist
Normal file
@@ -0,0 +1,15 @@
|
||||
<phpunit bootstrap="vendor/autoload.php" colors="true">
|
||||
<testsuites>
|
||||
<testsuite name="log">
|
||||
<directory suffix="Tests.php">tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<logging>
|
||||
<log type="coverage-clover" target="build/logs/clover.xml"/>
|
||||
</logging>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
25
old.vendor/consolidation/log/src/ConsoleLogLevel.php
Normal file
25
old.vendor/consolidation/log/src/ConsoleLogLevel.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
/**
|
||||
* Additional log levels for use in Console applications.
|
||||
*
|
||||
* ConsoleLogLevels may be used by methods of Symfony Command
|
||||
* in applications where it is known that the Consolidation logger
|
||||
* is in use. These log levels provide access to the 'success'
|
||||
* styled output method. Code in reusable libraries that may
|
||||
* be used with a standard Psr-3 logger should aviod using these
|
||||
* log levels.
|
||||
*
|
||||
* All ConsoleLogLevels should be interpreted as LogLevel\NOTICE.
|
||||
*
|
||||
* @author Greg Anderson <greg.1.anderson@greenknowe.org>
|
||||
*/
|
||||
class ConsoleLogLevel extends \Psr\Log\LogLevel
|
||||
{
|
||||
/**
|
||||
* Command successfully completed some operation.
|
||||
* Displayed at VERBOSITY_NORMAL.
|
||||
*/
|
||||
const SUCCESS = 'success';
|
||||
}
|
115
old.vendor/consolidation/log/src/LogOutputStyler.php
Normal file
115
old.vendor/consolidation/log/src/LogOutputStyler.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Psr\Log\LogLevel;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\OutputStyle;
|
||||
|
||||
/**
|
||||
* Styles log output based on format mappings provided in the constructor.
|
||||
*
|
||||
* Override for greater control.
|
||||
*/
|
||||
class LogOutputStyler extends UnstyledLogOutputStyler
|
||||
{
|
||||
const TASK_STYLE_INFO = 'fg=white;bg=cyan;options=bold';
|
||||
const TASK_STYLE_SUCCESS = 'fg=white;bg=green;options=bold';
|
||||
const TASK_STYLE_WARNING = 'fg=black;bg=yellow;options=bold;';
|
||||
const TASK_STYLE_ERROR = 'fg=white;bg=red;options=bold';
|
||||
|
||||
protected $defaultStyles = [
|
||||
'*' => LogLevel::INFO,
|
||||
];
|
||||
protected $labelStyles = [
|
||||
LogLevel::EMERGENCY => self::TASK_STYLE_ERROR,
|
||||
LogLevel::ALERT => self::TASK_STYLE_ERROR,
|
||||
LogLevel::CRITICAL => self::TASK_STYLE_ERROR,
|
||||
LogLevel::ERROR => self::TASK_STYLE_ERROR,
|
||||
LogLevel::WARNING => self::TASK_STYLE_WARNING,
|
||||
LogLevel::NOTICE => self::TASK_STYLE_INFO,
|
||||
LogLevel::INFO => self::TASK_STYLE_INFO,
|
||||
LogLevel::DEBUG => self::TASK_STYLE_INFO,
|
||||
ConsoleLogLevel::SUCCESS => self::TASK_STYLE_SUCCESS,
|
||||
];
|
||||
protected $messageStyles = [
|
||||
LogLevel::EMERGENCY => self::TASK_STYLE_ERROR,
|
||||
LogLevel::ALERT => self::TASK_STYLE_ERROR,
|
||||
LogLevel::CRITICAL => self::TASK_STYLE_ERROR,
|
||||
LogLevel::ERROR => self::TASK_STYLE_ERROR,
|
||||
LogLevel::WARNING => '',
|
||||
LogLevel::NOTICE => '',
|
||||
LogLevel::INFO => '',
|
||||
LogLevel::DEBUG => '',
|
||||
ConsoleLogLevel::SUCCESS => '',
|
||||
];
|
||||
|
||||
public function __construct($labelStyles = [], $messageStyles = [])
|
||||
{
|
||||
$this->labelStyles = $labelStyles + $this->labelStyles;
|
||||
$this->messageStyles = $messageStyles + $this->messageStyles;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultStyles()
|
||||
{
|
||||
return $this->defaultStyles;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function style($context)
|
||||
{
|
||||
$context += ['_style' => []];
|
||||
$context['_style'] += $this->defaultStyles();
|
||||
foreach ($context as $key => $value) {
|
||||
$styleKey = $key;
|
||||
if (!isset($context['_style'][$styleKey])) {
|
||||
$styleKey = '*';
|
||||
}
|
||||
if (is_string($value) && isset($context['_style'][$styleKey])) {
|
||||
$style = $context['_style'][$styleKey];
|
||||
$context[$key] = $this->wrapFormatString($context[$key], $style);
|
||||
}
|
||||
}
|
||||
return $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a string in a format element.
|
||||
*/
|
||||
protected function wrapFormatString($string, $style)
|
||||
{
|
||||
if ($style) {
|
||||
return "<{$style}>$string</>";
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up the label and message styles for the specified log level,
|
||||
* and use the log level as the label for the log message.
|
||||
*/
|
||||
protected function formatMessageByLevel($level, $message, $context)
|
||||
{
|
||||
$label = $level;
|
||||
return $this->formatMessage($label, $message, $context, $this->labelStyles[$level], $this->messageStyles[$level]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply styling with the provided label and message styles.
|
||||
*/
|
||||
protected function formatMessage($label, $message, $context, $labelStyle, $messageStyle = '')
|
||||
{
|
||||
if (!empty($messageStyle)) {
|
||||
$message = $this->wrapFormatString(" $message ", $messageStyle);
|
||||
}
|
||||
if (!empty($label)) {
|
||||
$message = ' ' . $this->wrapFormatString("[$label]", $labelStyle) . ' ' . $message;
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
105
old.vendor/consolidation/log/src/LogOutputStylerInterface.php
Normal file
105
old.vendor/consolidation/log/src/LogOutputStylerInterface.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Allow a log message to by styled.
|
||||
*
|
||||
* Styling happens in two phases:
|
||||
*
|
||||
* 1. Prior to message interpolation, context variables are styled
|
||||
* via the 'style()' method, using styles provided in the context
|
||||
* under the '_style' key, and also using styles provided by the
|
||||
* 'defaultStyles()' method.
|
||||
*
|
||||
* @see Symfony\Component\Console\Logger\ConsoleLogger::interpolate()
|
||||
*
|
||||
* 2. After message interpolation, an appropriate method based on the
|
||||
* log level will be called. StyledConsoleLogger::$formatFunctionMap
|
||||
* is used to map the LogLevel to a LogOutputStylerInterface method to call.
|
||||
*
|
||||
* It is possible to select the exact class to use as the log styler
|
||||
* in the constructor of StyledConsoleLogger, and the mapping from
|
||||
* LogLevel to format function can also be extended. It is possible to
|
||||
* add new format methods not defined here, if desired, so long as
|
||||
* any method named in the format function map is implemented by the
|
||||
* selected log styler class.
|
||||
*/
|
||||
interface LogOutputStylerInterface
|
||||
{
|
||||
const STYLE_CONTEXT_KEY = '_style';
|
||||
|
||||
/**
|
||||
* Return an array of default styles to use in an application.
|
||||
* The key of the style is the variable name that the style
|
||||
* should be applied to (or '*' to match all variables that have
|
||||
* no specific style set), and the value is the contents of the
|
||||
* Symfony style tag to wrap around the variable value.
|
||||
*
|
||||
* Example:
|
||||
* message: 'Running {command}'
|
||||
* context: ['command' => 'pwd']
|
||||
* default styles: ['*' => 'info']
|
||||
* result: 'Running <info>pwd</>'
|
||||
*/
|
||||
public function defaultStyles();
|
||||
|
||||
/**
|
||||
* Apply styles specified in the STYLE_CONTEXT_KEY context variable to
|
||||
* the other named variables stored in the context. The styles from
|
||||
* the context are unioned with the default styles.
|
||||
*/
|
||||
public function style($context);
|
||||
|
||||
/**
|
||||
* Create a wrapper object for the output stream. If this styler
|
||||
* does not require an output wrapper, it should just return
|
||||
* its $output parameter.
|
||||
*/
|
||||
public function createOutputWrapper(OutputInterface $output);
|
||||
|
||||
/**
|
||||
* Print an ordinary log message, usually unstyled.
|
||||
*/
|
||||
public function log($output, $level, $message, $context);
|
||||
|
||||
/**
|
||||
* Print a success message.
|
||||
*/
|
||||
public function success($output, $level, $message, $context);
|
||||
|
||||
/**
|
||||
* Print an error message. Used when log level is:
|
||||
* - LogLevel::EMERGENCY
|
||||
* - LogLevel::ALERT
|
||||
* - LogLevel::CRITICAL
|
||||
* - LogLevel::ERROR
|
||||
*/
|
||||
public function error($output, $level, $message, $context);
|
||||
|
||||
/**
|
||||
* Print a warning message. Used when log level is:
|
||||
* - LogLevel::WARNING
|
||||
*/
|
||||
public function warning($output, $level, $message, $context);
|
||||
|
||||
/**
|
||||
* Print a note. Similar to 'text', but may contain additional
|
||||
* styling (e.g. the task name). Used when log level is:
|
||||
* - LogLevel::NOTICE
|
||||
* - LogLevel::INFO
|
||||
* - LogLevel::DEBUG
|
||||
*
|
||||
* IMPORTANT: Symfony loggers only display LogLevel::NOTICE when the
|
||||
* the verbosity level is VERBOSITY_VERBOSE, unless overridden in the
|
||||
* constructor. Robo\Common\Logger emits LogLevel::NOTICE at
|
||||
* VERBOSITY_NORMAL so that these messages will always be displayed.
|
||||
*/
|
||||
public function note($output, $level, $message, $context);
|
||||
|
||||
/**
|
||||
* Print an error message. Not used by default by StyledConsoleLogger.
|
||||
*/
|
||||
public function caution($output, $level, $message, $context);
|
||||
}
|
268
old.vendor/consolidation/log/src/Logger.php
Normal file
268
old.vendor/consolidation/log/src/Logger.php
Normal file
@@ -0,0 +1,268 @@
|
||||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Psr\Log\AbstractLogger;
|
||||
use Psr\Log\InvalidArgumentException;
|
||||
use Psr\Log\LogLevel;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
|
||||
/**
|
||||
* Replacement for Symfony\Component\Console\Logger\ConsoleLogger.
|
||||
* Each of the different log level messages are routed through the
|
||||
* corresponding SymfonyStyle formatting method. Log messages are
|
||||
* always sent to stderr if the provided output object implements
|
||||
* ConsoleOutputInterface.
|
||||
*
|
||||
* Note that this class could extend ConsoleLogger if some methods
|
||||
* of that class were declared 'protected' instead of 'private'.
|
||||
*
|
||||
* @author Greg Anderson <greg.1.anderson@greenknowe.org>
|
||||
*/
|
||||
class Logger extends AbstractLogger implements StylableLoggerInterface, SettableLogOutputStreamInterface
|
||||
{
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
protected $output;
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
protected $error;
|
||||
/**
|
||||
* @var LogOutputStylerInterface
|
||||
*/
|
||||
protected $outputStyler;
|
||||
/**
|
||||
* @var OutputInterface|SymfonyStyle|other
|
||||
*/
|
||||
protected $outputStreamWrapper;
|
||||
protected $errorStreamWrapper;
|
||||
|
||||
protected $formatFunctionMap = [
|
||||
LogLevel::EMERGENCY => 'error',
|
||||
LogLevel::ALERT => 'error',
|
||||
LogLevel::CRITICAL => 'error',
|
||||
LogLevel::ERROR => 'error',
|
||||
LogLevel::WARNING => 'warning',
|
||||
LogLevel::NOTICE => 'note',
|
||||
LogLevel::INFO => 'note',
|
||||
LogLevel::DEBUG => 'note',
|
||||
ConsoleLogLevel::SUCCESS => 'success',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param OutputInterface $output
|
||||
* @param array $verbosityLevelMap
|
||||
* @param array $formatLevelMap
|
||||
* @param array $formatFunctionMap
|
||||
*/
|
||||
public function __construct(OutputInterface $output, array $verbosityLevelMap = array(), array $formatLevelMap = array(), array $formatFunctionMap = array())
|
||||
{
|
||||
$this->output = $output;
|
||||
|
||||
$this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap;
|
||||
$this->formatLevelMap = $formatLevelMap + $this->formatLevelMap;
|
||||
$this->formatFunctionMap = $formatFunctionMap + $this->formatFunctionMap;
|
||||
}
|
||||
|
||||
public function setLogOutputStyler(LogOutputStylerInterface $outputStyler, array $formatFunctionMap = array())
|
||||
{
|
||||
$this->outputStyler = $outputStyler;
|
||||
$this->formatFunctionMap = $formatFunctionMap + $this->formatFunctionMap;
|
||||
$this->outputStreamWrapper = null;
|
||||
$this->errorStreamWrapper = null;
|
||||
}
|
||||
|
||||
public function getLogOutputStyler()
|
||||
{
|
||||
if (!isset($this->outputStyler)) {
|
||||
$this->outputStyler = new SymfonyLogOutputStyler();
|
||||
}
|
||||
return $this->outputStyler;
|
||||
}
|
||||
|
||||
protected function getOutputStream()
|
||||
{
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
protected function getErrorStream()
|
||||
{
|
||||
if (!isset($this->error)) {
|
||||
$output = $this->getOutputStream();
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$output = $output->getErrorOutput();
|
||||
}
|
||||
$this->error = $output;
|
||||
}
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function setOutputStream($output)
|
||||
{
|
||||
$this->output = $output;
|
||||
$this->outputStreamWrapper = null;
|
||||
}
|
||||
|
||||
public function setErrorStream($error)
|
||||
{
|
||||
$this->error = $error;
|
||||
$this->errorStreamWrapper = null;
|
||||
}
|
||||
|
||||
protected function getOutputStreamWrapper()
|
||||
{
|
||||
if (!isset($this->outputStreamWrapper)) {
|
||||
$this->outputStreamWrapper = $this->getLogOutputStyler()->createOutputWrapper($this->getOutputStream());
|
||||
}
|
||||
return $this->outputStreamWrapper;
|
||||
}
|
||||
|
||||
protected function getErrorStreamWrapper()
|
||||
{
|
||||
if (!isset($this->errorStreamWrapper)) {
|
||||
$this->errorStreamWrapper = $this->getLogOutputStyler()->createOutputWrapper($this->getErrorStream());
|
||||
}
|
||||
return $this->errorStreamWrapper;
|
||||
}
|
||||
|
||||
protected function getOutputStreamForLogLevel($level)
|
||||
{
|
||||
// Write to the error output if necessary and available.
|
||||
// Usually, loggers that log to a terminal should send
|
||||
// all log messages to stderr.
|
||||
if (array_key_exists($level, $this->formatLevelMap) && ($this->formatLevelMap[$level] !== self::ERROR)) {
|
||||
return $this->getOutputStreamWrapper();
|
||||
}
|
||||
return $this->getErrorStreamWrapper();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function log($level, $message, array $context = array())
|
||||
{
|
||||
// We use the '_level' context variable to allow log messages
|
||||
// to be logged at one level (e.g. NOTICE) and formatted at another
|
||||
// level (e.g. SUCCESS). This helps in instances where we want
|
||||
// to style log messages at a custom log level that might not
|
||||
// be available in all loggers. If the logger does not recognize
|
||||
// the log level, then it is treated like the original log level.
|
||||
if (array_key_exists('_level', $context) && array_key_exists($context['_level'], $this->verbosityLevelMap)) {
|
||||
$level = $context['_level'];
|
||||
}
|
||||
// It is a runtime error if someone logs at a log level that
|
||||
// we do not recognize.
|
||||
if (!isset($this->verbosityLevelMap[$level])) {
|
||||
throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
|
||||
}
|
||||
|
||||
// Write to the error output if necessary and available.
|
||||
// Usually, loggers that log to a terminal should send
|
||||
// all log messages to stderr.
|
||||
$outputStreamWrapper = $this->getOutputStreamForLogLevel($level);
|
||||
|
||||
// Ignore messages that are not at the right verbosity level
|
||||
if ($this->getOutputStream()->getVerbosity() >= $this->verbosityLevelMap[$level]) {
|
||||
$this->doLog($outputStreamWrapper, $level, $message, $context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interpolate and style the message, and then send it to the log.
|
||||
*/
|
||||
protected function doLog($outputStreamWrapper, $level, $message, $context)
|
||||
{
|
||||
$formatFunction = 'log';
|
||||
if (array_key_exists($level, $this->formatFunctionMap)) {
|
||||
$formatFunction = $this->formatFunctionMap[$level];
|
||||
}
|
||||
$interpolated = $this->interpolate(
|
||||
$message,
|
||||
$this->getLogOutputStyler()->style($context)
|
||||
);
|
||||
$this->getLogOutputStyler()->$formatFunction(
|
||||
$outputStreamWrapper,
|
||||
$level,
|
||||
$interpolated,
|
||||
$context
|
||||
);
|
||||
}
|
||||
|
||||
public function success($message, array $context = array())
|
||||
{
|
||||
$this->log(ConsoleLogLevel::SUCCESS, $message, $context);
|
||||
}
|
||||
|
||||
// The functions below could be eliminated if made `protected` intead
|
||||
// of `private` in ConsoleLogger
|
||||
|
||||
const INFO = 'info';
|
||||
const ERROR = 'error';
|
||||
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
//private $output;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $verbosityLevelMap = [
|
||||
LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL,
|
||||
LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL,
|
||||
LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL,
|
||||
LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL,
|
||||
LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL,
|
||||
LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE,
|
||||
LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
|
||||
LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
|
||||
ConsoleLogLevel::SUCCESS => OutputInterface::VERBOSITY_NORMAL,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*
|
||||
* Send all log messages to stderr. Symfony should have the same default.
|
||||
* See: https://en.wikipedia.org/wiki/Standard_streams
|
||||
* "Standard error was added to Unix after several wasted phototypesetting runs ended with error messages being typeset instead of displayed on the user's terminal."
|
||||
*/
|
||||
private $formatLevelMap = [
|
||||
LogLevel::EMERGENCY => self::ERROR,
|
||||
LogLevel::ALERT => self::ERROR,
|
||||
LogLevel::CRITICAL => self::ERROR,
|
||||
LogLevel::ERROR => self::ERROR,
|
||||
LogLevel::WARNING => self::ERROR,
|
||||
LogLevel::NOTICE => self::ERROR,
|
||||
LogLevel::INFO => self::ERROR,
|
||||
LogLevel::DEBUG => self::ERROR,
|
||||
ConsoleLogLevel::SUCCESS => self::ERROR,
|
||||
];
|
||||
|
||||
/**
|
||||
* Interpolates context values into the message placeholders.
|
||||
*
|
||||
* @author PHP Framework Interoperability Group
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function interpolate($message, array $context)
|
||||
{
|
||||
// build a replacement array with braces around the context keys
|
||||
$replace = array();
|
||||
foreach ($context as $key => $val) {
|
||||
if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) {
|
||||
$replace[sprintf('{%s}', $key)] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
// interpolate replacement values into the message and return
|
||||
return strtr($message, $replace);
|
||||
}
|
||||
}
|
168
old.vendor/consolidation/log/src/LoggerManager.php
Normal file
168
old.vendor/consolidation/log/src/LoggerManager.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Psr\Log\AbstractLogger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\InvalidArgumentException;
|
||||
use Psr\Log\LogLevel;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* LoggerManager is a PSR-3 logger that can delegate
|
||||
* log messages to other loggers. This is ideal if
|
||||
* you need to inject a logger into various objects
|
||||
* in your application, but need to change the way that
|
||||
* the application logs later.
|
||||
*
|
||||
* @author Greg Anderson <greg.1.anderson@greenknowe.org>
|
||||
*/
|
||||
class LoggerManager extends AbstractLogger implements StylableLoggerInterface, SettableLogOutputStreamInterface
|
||||
{
|
||||
/** @var LoggerInterface[] */
|
||||
protected $loggers = [];
|
||||
/** @var LoggerInterface */
|
||||
protected $fallbackLogger = null;
|
||||
/** @var LogOutputStylerInterface */
|
||||
protected $outputStyler;
|
||||
/** @var array */
|
||||
protected $formatFunctionMap = [];
|
||||
/** @var OutputInterface */
|
||||
protected $outputStream;
|
||||
/** @var OutputInterface */
|
||||
protected $errorStream;
|
||||
|
||||
/**
|
||||
* reset removes all loggers from the manager.
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->loggers = [];
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* setLogOutputStyler will remember a style that
|
||||
* should be applied to every stylable logger
|
||||
* added to this manager.
|
||||
*/
|
||||
public function setLogOutputStyler(LogOutputStylerInterface $outputStyler, array $formatFunctionMap = array())
|
||||
{
|
||||
$this->outputStyler = $outputStyler;
|
||||
$this->formatFunctionMap = $this->formatFunctionMap;
|
||||
|
||||
foreach ($this->getLoggers() as $logger) {
|
||||
if ($logger instanceof StylableLoggerInterface) {
|
||||
$logger->setLogOutputStyler($this->outputStyler, $this->formatFunctionMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* setOutputStream will remember an output stream that should be
|
||||
* applied to every logger added to this manager.
|
||||
*/
|
||||
public function setOutputStream($output)
|
||||
{
|
||||
$this->outputStream = $output;
|
||||
foreach ($this->getLoggers() as $logger) {
|
||||
if ($logger instanceof SettableLogOutputStreamInterface) {
|
||||
$logger->setOutputStream($this->outputStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* setErrorStream will remember an error stream that should be
|
||||
* applied to every logger added to this manager.
|
||||
*/
|
||||
public function setErrorStream($error)
|
||||
{
|
||||
$this->errorStream = $error;
|
||||
foreach ($this->getLoggers() as $logger) {
|
||||
if ($logger instanceof SettableLogOutputStreamInterface) {
|
||||
$logger->setErrorStream($this->errorStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* add adds a named logger to the manager,
|
||||
* replacing any logger of the same name.
|
||||
*
|
||||
* @param string $name Name of logger to add
|
||||
* @param LoggerInterface $logger Logger to send messages to
|
||||
*/
|
||||
public function add($name, LoggerInterface $logger)
|
||||
{
|
||||
// If this manager has been given a log style,
|
||||
// and the logger being added accepts a log
|
||||
// style, then copy our style to the logger
|
||||
// being added.
|
||||
if ($this->outputStyler && $logger instanceof StylableLoggerInterface) {
|
||||
$logger->setLogOutputStyler($this->outputStyler, $this->formatFunctionMap);
|
||||
}
|
||||
if ($logger instanceof SettableLogOutputStreamInterface) {
|
||||
if ($this->outputStream) {
|
||||
$logger->setOutputStream($this->outputStream);
|
||||
}
|
||||
if ($this->errorStream) {
|
||||
$logger->setErrorStream($this->errorStream);
|
||||
}
|
||||
}
|
||||
$this->loggers[$name] = $logger;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* remove a named logger from the manager.
|
||||
*
|
||||
* @param string $name Name of the logger to remove.
|
||||
*/
|
||||
public function remove($name)
|
||||
{
|
||||
unset($this->loggers[$name]);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* fallbackLogger provides a logger that will
|
||||
* be used only in instances where someone logs
|
||||
* to the logger manager at a time when there
|
||||
* are no other loggers registered. If there is
|
||||
* no fallback logger, then the log messages
|
||||
* are simply dropped.
|
||||
*
|
||||
* @param LoggerInterface $logger Logger to use as the fallback logger
|
||||
*/
|
||||
public function fallbackLogger(LoggerInterface $logger)
|
||||
{
|
||||
$this->fallbackLogger = $logger;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function log($level, $message, array $context = array())
|
||||
{
|
||||
foreach ($this->getLoggers() as $logger) {
|
||||
$logger->log($level, $message, $context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return either the list of registered loggers,
|
||||
* or a single-element list containing only the
|
||||
* fallback logger.
|
||||
*/
|
||||
protected function getLoggers()
|
||||
{
|
||||
if (!empty($this->loggers)) {
|
||||
return $this->loggers;
|
||||
}
|
||||
if (isset($this->fallbackLogger)) {
|
||||
return [ $this->fallbackLogger ];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Interface that indicates that a logger's output / error streams
|
||||
* are settable.
|
||||
*
|
||||
* @author Greg Anderson <greg.1.anderson@greenknowe.org>
|
||||
*/
|
||||
interface SettableLogOutputStreamInterface
|
||||
{
|
||||
/**
|
||||
* @param OutputInterface $output
|
||||
*/
|
||||
public function setOutputStream($output);
|
||||
|
||||
/**
|
||||
* @param OutputInterface $error
|
||||
*/
|
||||
public function setErrorStream($error);
|
||||
}
|
16
old.vendor/consolidation/log/src/StylableLoggerInterface.php
Normal file
16
old.vendor/consolidation/log/src/StylableLoggerInterface.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
|
||||
/**
|
||||
* StylableLoggerInterface indicates that a logger
|
||||
* can receive a LogOutputStyler.
|
||||
*
|
||||
* @author Greg Anderson <greg.1.anderson@greenknowe.org>
|
||||
*/
|
||||
interface StylableLoggerInterface
|
||||
{
|
||||
public function setLogOutputStyler(LogOutputStylerInterface $outputStyler, array $formatFunctionMap = array());
|
||||
}
|
65
old.vendor/consolidation/log/src/SymfonyLogOutputStyler.php
Normal file
65
old.vendor/consolidation/log/src/SymfonyLogOutputStyler.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Style log messages with Symfony\Component\Console\Style\SymfonyStyle.
|
||||
* No context variable styling is done.
|
||||
*
|
||||
* This is the appropriate styler to use if your desire is to replace
|
||||
* the use of SymfonyStyle with a Psr-3 logger without changing the
|
||||
* appearance of your application's output.
|
||||
*/
|
||||
class SymfonyLogOutputStyler implements LogOutputStylerInterface
|
||||
{
|
||||
public function defaultStyles()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function style($context)
|
||||
{
|
||||
return $context;
|
||||
}
|
||||
|
||||
public function createOutputWrapper(OutputInterface $output)
|
||||
{
|
||||
// SymfonyStyle & c. contain both input and output functions,
|
||||
// but we only need the output methods here. Create a stand-in
|
||||
// input object to satisfy the SymfonyStyle constructor.
|
||||
return new SymfonyStyle(new StringInput(''), $output);
|
||||
}
|
||||
|
||||
public function log($symfonyStyle, $level, $message, $context)
|
||||
{
|
||||
$symfonyStyle->text($message);
|
||||
}
|
||||
|
||||
public function success($symfonyStyle, $level, $message, $context)
|
||||
{
|
||||
$symfonyStyle->success($message);
|
||||
}
|
||||
|
||||
public function error($symfonyStyle, $level, $message, $context)
|
||||
{
|
||||
$symfonyStyle->error($message);
|
||||
}
|
||||
|
||||
public function warning($symfonyStyle, $level, $message, $context)
|
||||
{
|
||||
$symfonyStyle->warning($message);
|
||||
}
|
||||
|
||||
public function note($symfonyStyle, $level, $message, $context)
|
||||
{
|
||||
$symfonyStyle->note($message);
|
||||
}
|
||||
|
||||
public function caution($symfonyStyle, $level, $message, $context)
|
||||
{
|
||||
$symfonyStyle->caution($message);
|
||||
}
|
||||
}
|
97
old.vendor/consolidation/log/src/UnstyledLogOutputStyler.php
Normal file
97
old.vendor/consolidation/log/src/UnstyledLogOutputStyler.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\OutputStyle;
|
||||
|
||||
/**
|
||||
* Base class that provides basic unstyled output.
|
||||
*/
|
||||
class UnstyledLogOutputStyler implements LogOutputStylerInterface
|
||||
{
|
||||
public function createOutputWrapper(OutputInterface $output)
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultStyles()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function style($context)
|
||||
{
|
||||
return $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function write($output, $message, $context)
|
||||
{
|
||||
$output->writeln($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function log($output, $level, $message, $context)
|
||||
{
|
||||
return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function success($output, $level, $message, $context)
|
||||
{
|
||||
return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function error($output, $level, $message, $context)
|
||||
{
|
||||
return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function warning($output, $level, $message, $context)
|
||||
{
|
||||
return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function note($output, $level, $message, $context)
|
||||
{
|
||||
return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function caution($output, $level, $message, $context)
|
||||
{
|
||||
return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up the label and message styles for the specified log level,
|
||||
* and use the log level as the label for the log message.
|
||||
*/
|
||||
protected function formatMessageByLevel($level, $message, $context)
|
||||
{
|
||||
return " [$level] $message";
|
||||
}
|
||||
}
|
55
old.vendor/consolidation/log/tests/LogMethodTests.php
Normal file
55
old.vendor/consolidation/log/tests/LogMethodTests.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class LogMethodTests extends TestCase
|
||||
{
|
||||
protected $output;
|
||||
protected $logger;
|
||||
|
||||
function setup(): void {
|
||||
$this->output = new BufferedOutput();
|
||||
$this->output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
|
||||
$this->logger = new Logger($this->output);
|
||||
$this->logger->setLogOutputStyler(new UnstyledLogOutputStyler());
|
||||
}
|
||||
|
||||
function testError() {
|
||||
$this->logger->error('Do not enter - wrong way.');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [error] Do not enter - wrong way.', $outputText);
|
||||
}
|
||||
|
||||
function testWarning() {
|
||||
$this->logger->warning('Steep grade.');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [warning] Steep grade.', $outputText);
|
||||
}
|
||||
|
||||
function testNotice() {
|
||||
$this->logger->notice('No loitering.');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [notice] No loitering.', $outputText);
|
||||
}
|
||||
|
||||
function testInfo() {
|
||||
$this->logger->info('Scenic route.');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [info] Scenic route.', $outputText);
|
||||
}
|
||||
|
||||
function testDebug() {
|
||||
$this->logger->debug('Counter incremented.');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [debug] Counter incremented.', $outputText);
|
||||
}
|
||||
|
||||
function testSuccess() {
|
||||
$this->logger->success('It worked!');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [success] It worked!', $outputText);
|
||||
}
|
||||
}
|
71
old.vendor/consolidation/log/tests/LoggerManagerTests.php
Normal file
71
old.vendor/consolidation/log/tests/LoggerManagerTests.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class LoggerManagerTests extends TestCase
|
||||
{
|
||||
protected $output;
|
||||
protected $logger;
|
||||
|
||||
function testLoggerManager()
|
||||
{
|
||||
$fallbackOutput = new BufferedOutput();
|
||||
$fallbackOutput->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
|
||||
$fallbackLogger = new Logger($fallbackOutput);
|
||||
$fallbackLogger->notice('This is the fallback logger');
|
||||
|
||||
$primaryOutput = new BufferedOutput();
|
||||
$primaryOutput->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
|
||||
$primaryLogger = new Logger($primaryOutput);
|
||||
$primaryLogger->notice('This is the primary logger');
|
||||
|
||||
$replacementOutput = new BufferedOutput();
|
||||
$replacementOutput->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
|
||||
$replacementLogger = new Logger($replacementOutput);
|
||||
$replacementLogger->notice('This is the replacement logger');
|
||||
|
||||
$logger = new LoggerManager();
|
||||
|
||||
$logger->notice('Uninitialized logger.');
|
||||
$logger->fallbackLogger($fallbackLogger);
|
||||
$logger->notice('Logger with fallback.');
|
||||
$logger->add('default', $primaryLogger);
|
||||
$logger->notice('Primary logger');
|
||||
$logger->add('default', $replacementLogger);
|
||||
$logger->notice('Replaced logger');
|
||||
$logger->reset();
|
||||
$logger->notice('Reset loggers');
|
||||
|
||||
$fallbackActual = rtrim($fallbackOutput->fetch());
|
||||
$primaryActual = rtrim($primaryOutput->fetch());
|
||||
$replacementActual = rtrim($replacementOutput->fetch());
|
||||
|
||||
$actual = "Fallback:\n====\n$fallbackActual\nPrimary:\n====\n$primaryActual\nReplacement:\n====\n$replacementActual";
|
||||
|
||||
$actual = preg_replace('#\r\n#ms', "\n", $actual);
|
||||
$actual = preg_replace('# *$#ms', '', $actual);
|
||||
$actual = preg_replace('#^ *$\n#ms', '', $actual);
|
||||
|
||||
$expected = <<< __EOT__
|
||||
Fallback:
|
||||
====
|
||||
! [NOTE] This is the fallback logger
|
||||
! [NOTE] Logger with fallback.
|
||||
! [NOTE] Reset loggers
|
||||
Primary:
|
||||
====
|
||||
! [NOTE] This is the primary logger
|
||||
! [NOTE] Primary logger
|
||||
Replacement:
|
||||
====
|
||||
! [NOTE] This is the replacement logger
|
||||
! [NOTE] Replaced logger
|
||||
__EOT__;
|
||||
|
||||
$expected = preg_replace('#\r\n#ms', "\n", $expected);
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Psr\Log\LogLevel;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use Consolidation\TestUtils\TestDataPermuter;
|
||||
|
||||
class LoggerVerbosityAndStyleTests extends TestCase
|
||||
{
|
||||
protected $output;
|
||||
protected $logger;
|
||||
|
||||
function setup(): void {
|
||||
$this->output = new BufferedOutput();
|
||||
//$this->output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
|
||||
$this->logger = new Logger($this->output);
|
||||
}
|
||||
|
||||
public static function logTestValues()
|
||||
{
|
||||
/**
|
||||
* Use TEST_ALL_LOG_LEVELS to ensure that output is the same
|
||||
* in instances where the output does not vary by log level.
|
||||
*/
|
||||
$TEST_ALL_LOG_LEVELS = [
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
OutputInterface::VERBOSITY_VERY_VERBOSE,
|
||||
OutputInterface::VERBOSITY_VERBOSE,
|
||||
OutputInterface::VERBOSITY_NORMAL
|
||||
];
|
||||
|
||||
// Tests that return the same value for multiple inputs
|
||||
// may use the expandProviderDataArrays method, and list
|
||||
// repeated scalars as array values. All permutations of
|
||||
// all array items will be calculated, and one test will
|
||||
// be generated for each one.
|
||||
return TestDataPermuter::expandProviderDataArrays([
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
$TEST_ALL_LOG_LEVELS,
|
||||
LogLevel::EMERGENCY,
|
||||
'The planet is melting. Consume less.',
|
||||
' [emergency] The planet is melting. Consume less.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
$TEST_ALL_LOG_LEVELS,
|
||||
LogLevel::ALERT,
|
||||
'Masks required.',
|
||||
' [alert] Masks required.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
$TEST_ALL_LOG_LEVELS,
|
||||
LogLevel::CRITICAL,
|
||||
'Reactor meltdown imminent.',
|
||||
' [critical] Reactor meltdown imminent.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
$TEST_ALL_LOG_LEVELS,
|
||||
LogLevel::ERROR,
|
||||
'Do not enter - wrong way.',
|
||||
' [error] Do not enter - wrong way.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
$TEST_ALL_LOG_LEVELS,
|
||||
LogLevel::WARNING,
|
||||
'Steep grade.',
|
||||
' [warning] Steep grade.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
[
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
OutputInterface::VERBOSITY_VERY_VERBOSE,
|
||||
OutputInterface::VERBOSITY_VERBOSE,
|
||||
],
|
||||
LogLevel::NOTICE,
|
||||
'No loitering.',
|
||||
' [notice] No loitering.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_NORMAL,
|
||||
LogLevel::NOTICE,
|
||||
'No loitering.',
|
||||
'',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::INFO,
|
||||
'Scenic route.',
|
||||
' [info] Scenic route.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::DEBUG,
|
||||
'Counter incremented.',
|
||||
' [debug] Counter incremented.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
[
|
||||
OutputInterface::VERBOSITY_VERY_VERBOSE,
|
||||
OutputInterface::VERBOSITY_VERBOSE,
|
||||
OutputInterface::VERBOSITY_NORMAL
|
||||
],
|
||||
LogLevel::DEBUG,
|
||||
'Counter incremented.',
|
||||
'',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
$TEST_ALL_LOG_LEVELS,
|
||||
ConsoleLogLevel::SUCCESS,
|
||||
'It worked!',
|
||||
' [success] It worked!',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\LogOutputStyler',
|
||||
OutputInterface::VERBOSITY_NORMAL,
|
||||
ConsoleLogLevel::SUCCESS,
|
||||
'It worked!',
|
||||
' [success] It worked!',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\SymfonyLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::WARNING,
|
||||
'Steep grade.',
|
||||
"\n [WARNING] Steep grade.",
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\SymfonyLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::NOTICE,
|
||||
'No loitering.',
|
||||
"\n ! [NOTE] No loitering.",
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\SymfonyLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::INFO,
|
||||
'Scenic route.',
|
||||
"\n ! [NOTE] Scenic route.",
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\SymfonyLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::DEBUG,
|
||||
'Counter incremented.',
|
||||
"\n ! [NOTE] Counter incremented.",
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\SymfonyLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_NORMAL,
|
||||
ConsoleLogLevel::SUCCESS,
|
||||
'It worked!',
|
||||
"\n [OK] It worked!",
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is our only test method. It accepts all of the
|
||||
* permuted data from the data provider, and runs one
|
||||
* test on each one.
|
||||
*
|
||||
* @dataProvider logTestValues
|
||||
*/
|
||||
function testLogging($styleClass, $verbocity, $level, $message, $expected) {
|
||||
$logStyler = new $styleClass;
|
||||
$this->logger->setLogOutputStyler($logStyler);
|
||||
$this->output->setVerbosity($verbocity);
|
||||
$this->logger->log($level, $message);
|
||||
$outputText = rtrim($this->output->fetch(), "\n\r\t ");
|
||||
$outputText = preg_replace('#\r\n#ms', "\n", $outputText);
|
||||
$expected = preg_replace('#\r\n#ms', "\n", $expected);
|
||||
$this->assertEquals($expected, $outputText);
|
||||
}
|
||||
}
|
81
old.vendor/consolidation/log/tests/src/TestDataPermuter.php
Normal file
81
old.vendor/consolidation/log/tests/src/TestDataPermuter.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
namespace Consolidation\TestUtils;
|
||||
|
||||
class TestDataPermuter
|
||||
{
|
||||
/**
|
||||
* Given an array of test data, where each element is
|
||||
* data to pass to a unit test AND each unit test requires
|
||||
* only scalar or object test value, find each array
|
||||
* in each test, and build all of the permutations for all
|
||||
* of the data provided in arrays.
|
||||
*/
|
||||
public static function expandProviderDataArrays($tests)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach($tests as $test) {
|
||||
$subsitutionIndex = 1;
|
||||
$permutationData = [];
|
||||
$replacements = [];
|
||||
|
||||
foreach($test as $testValue) {
|
||||
if (is_array($testValue)) {
|
||||
$key = "{SUB$subsitutionIndex}";
|
||||
$replacements[$key] = $testValue;
|
||||
$permutationData[] = $key;
|
||||
}
|
||||
else {
|
||||
$permutationData[] = $testValue;
|
||||
}
|
||||
}
|
||||
|
||||
$permuted = static::expandDataMatrix([$permutationData], $replacements);
|
||||
$result = array_merge($result, $permuted);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an array of test data, where each element is
|
||||
* data to pass to a unit test, expand all of the
|
||||
* permutations of $replacements, where each key
|
||||
* holds the placeholder value, and the value holds
|
||||
* an array of replacement values.
|
||||
*/
|
||||
public static function expandDataMatrix($tests, $replacements)
|
||||
{
|
||||
foreach($replacements as $substitute => $values) {
|
||||
$tests = static::expandOneValue($tests, $substitute, $values);
|
||||
}
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an array of test data, where each element is
|
||||
* data to pass to a unit test, find any element in any
|
||||
* one test item whose value is exactly $substitute.
|
||||
* Make a new test item for every item in $values, using
|
||||
* each as the substitution for $substitute.
|
||||
*/
|
||||
public static function expandOneValue($tests, $substitute, $values)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach($tests as $test) {
|
||||
$position = array_search($substitute, $test);
|
||||
if ($position === FALSE) {
|
||||
$result[] = $test;
|
||||
}
|
||||
else {
|
||||
foreach($values as $replacement) {
|
||||
$test[$position] = $replacement;
|
||||
$result[] = $test;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user