|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Webmozarts Console Parallelization package. |
| 5 | + * |
| 6 | + * (c) Webmozarts GmbH <office@webmozarts.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +declare(strict_types=1); |
| 13 | + |
| 14 | +namespace Webmozarts\Console\Parallelization\Logger; |
| 15 | + |
| 16 | +use Throwable; |
| 17 | +use Webmozarts\Console\Parallelization\Configuration; |
| 18 | +use function func_get_args; |
| 19 | + |
| 20 | +/** |
| 21 | + * Base logger that can be extended to override only a few methods of a logger |
| 22 | + * and delegate the others to the decorated logger. |
| 23 | + */ |
| 24 | +abstract class DecoratorLogger implements Logger |
| 25 | +{ |
| 26 | + private Logger $decoratedLogger; |
| 27 | + |
| 28 | + public function __construct(Logger $decoratedLogger) |
| 29 | + { |
| 30 | + $this->decoratedLogger = $decoratedLogger; |
| 31 | + } |
| 32 | + |
| 33 | + public function logConfiguration( |
| 34 | + Configuration $configuration, |
| 35 | + int $batchSize, |
| 36 | + ?int $numberOfItems, |
| 37 | + string $itemName, |
| 38 | + bool $shouldSpawnChildProcesses |
| 39 | + ): void { |
| 40 | + $this->decoratedLogger->logConfiguration(...func_get_args()); |
| 41 | + } |
| 42 | + |
| 43 | + public function logStart(?int $numberOfItems): void |
| 44 | + { |
| 45 | + $this->decoratedLogger->logStart(...func_get_args()); |
| 46 | + } |
| 47 | + |
| 48 | + public function logAdvance(int $steps = 1): void |
| 49 | + { |
| 50 | + $this->decoratedLogger->logAdvance(...func_get_args()); |
| 51 | + } |
| 52 | + |
| 53 | + public function logFinish(string $itemName): void |
| 54 | + { |
| 55 | + $this->decoratedLogger->logFinish(...func_get_args()); |
| 56 | + } |
| 57 | + |
| 58 | + public function logItemProcessingFailed(string $item, Throwable $throwable): void |
| 59 | + { |
| 60 | + $this->decoratedLogger->logItemProcessingFailed(...func_get_args()); |
| 61 | + } |
| 62 | + |
| 63 | + public function logChildProcessStarted(int $index, int $pid, string $commandName): void |
| 64 | + { |
| 65 | + $this->decoratedLogger->logChildProcessStarted(...func_get_args()); |
| 66 | + } |
| 67 | + |
| 68 | + public function logChildProcessFinished(int $index): void |
| 69 | + { |
| 70 | + $this->decoratedLogger->logChildProcessFinished(...func_get_args()); |
| 71 | + } |
| 72 | + |
| 73 | + public function logUnexpectedChildProcessOutput( |
| 74 | + int $index, |
| 75 | + ?int $pid, |
| 76 | + string $type, |
| 77 | + string $buffer, |
| 78 | + string $progressSymbol |
| 79 | + ): void { |
| 80 | + $this->decoratedLogger->logUnexpectedChildProcessOutput(...func_get_args()); |
| 81 | + } |
| 82 | +} |
0 commit comments