php-etl / log-plugin
Plugins for adding Logging support
v0.3.1
2023-04-21 07:52 UTC
Requires
- php: ^8.2
- nikic/php-parser: ^4.15
- php-etl/configurator-contracts: 0.8.*
- symfony/config: ^6.0
Requires (Dev)
- elasticsearch/elasticsearch: ~7.0
- friendsofphp/php-cs-fixer: ^3.0
- graylog2/gelf-php: ^2.0
- infection/infection: ^0.26.18
- mikey179/vfsstream: ^1.6
- monolog/monolog: ^3.3.0
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.0
- rector/rector: ^0.15
- symfony/console: ^6.0
- symfony/yaml: ^6.0
This package is auto-updated.
Last update: 2024-11-21 11:15:48 UTC
README
Goal
This package aims at integrating logging capabilities in the Pipeline stack.
Principles
The tools in this library will produce executable PHP sources, using an intermediate Abstract Syntax Tree from nikic/php-parser. This intermediate format helps you combine the code produced by this library with other packages from Middleware.
Configuration format
Disabling logging
logger: null: ~
Logging to STDERR
logger: stderr: ~
Usage
This library will build for you logging capabilities inside a pipeline.
You can use the following PHP script to test and print the result of your configuration.
<?php require __DIR__ . '/../vendor/autoload.php'; use Kiboko\Plugin\Log; use PhpParser\Node; use PhpParser\PrettyPrinter; use Symfony\Component\Console; use Symfony\Component\Yaml; $input = new Console\Input\ArgvInput($argv); $output = new Console\Output\ConsoleOutput(); class DefaultCommand extends Console\Command\Command { protected static $defaultName = 'test'; protected function configure() { $this->addArgument('file', Console\Input\InputArgument::REQUIRED); } protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) { $factory = new Log\Service(); $style = new Console\Style\SymfonyStyle( $input, $output, ); $config = Yaml\Yaml::parse(input: file_get_contents($input->getArgument('file'))); $style->section('Validation'); $style->writeln($factory->validate($config) ? '<info>ok</info>' : '<error>failed</error>'); $style->section('Normalized Config'); $style->writeln(\json_encode($config = $factory->normalize($config), JSON_PRETTY_PRINT)); $style->section('Generated code'); $style->writeln((new PrettyPrinter\Standard())->prettyPrintFile([ new Node\Stmt\Return_($factory->compile($config)->getNode()), ])); return 0; } } (new Console\Application()) ->add(new DefaultCommand()) ->run($input, $output) ;