Skip to content

Commit 8b35686

Browse files
authored
Rename logger methods (#170)
Technically should only be BC breaks if coming from the previous beta and implementing your own logger.
1 parent bc5564d commit 8b35686

10 files changed

+73
-73
lines changed

src/Logger/Logger.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ public function logConfiguration(
3737
/**
3838
* @param 0|positive-int|null $numberOfItems
3939
*/
40-
public function startProgress(?int $numberOfItems): void;
40+
public function logStart(?int $numberOfItems): void;
4141

4242
/**
4343
* @param positive-int|0 $steps
4444
*/
45-
public function advance(int $steps = 1): void;
45+
public function logAdvance(int $steps = 1): void;
4646

4747
/**
4848
* @param string $itemName Name of the item; Already in the singular or plural form.
4949
*/
50-
public function finish(string $itemName): void;
50+
public function logFinish(string $itemName): void;
5151

5252
public function logItemProcessingFailed(string $item, Throwable $throwable): void;
5353

@@ -56,9 +56,9 @@ public function logItemProcessingFailed(string $item, Throwable $throwable): voi
5656
* with the Symfony command name which is just an element of
5757
* the command.
5858
*/
59-
public function logCommandStarted(string $commandName): void;
59+
public function logChildProcessStarted(string $commandName): void;
6060

61-
public function logCommandFinished(): void;
61+
public function logChildProcessFinished(): void;
6262

6363
/**
6464
* Logs the "unexpected" child output. By unexpected is meant that the main
@@ -67,5 +67,5 @@ public function logCommandFinished(): void;
6767
*
6868
* @param string $buffer Child process output.
6969
*/
70-
public function logUnexpectedOutput(string $buffer, string $progressSymbol): void;
70+
public function logUnexpectedChildProcessOutput(string $buffer, string $progressSymbol): void;
7171
}

src/Logger/NullLogger.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ public function logConfiguration(
2828
// Do nothing.
2929
}
3030

31-
public function startProgress(?int $numberOfItems): void
31+
public function logStart(?int $numberOfItems): void
3232
{
3333
// Do nothing.
3434
}
3535

36-
public function advance(int $steps = 1): void
36+
public function logAdvance(int $steps = 1): void
3737
{
3838
// Do nothing.
3939
}
4040

41-
public function finish(string $itemName): void
41+
public function logFinish(string $itemName): void
4242
{
4343
// Do nothing.
4444
}
@@ -48,17 +48,17 @@ public function logItemProcessingFailed(string $item, Throwable $throwable): voi
4848
// Do nothing.
4949
}
5050

51-
public function logCommandStarted(string $commandName): void
51+
public function logChildProcessStarted(string $commandName): void
5252
{
5353
// Do nothing.
5454
}
5555

56-
public function logCommandFinished(): void
56+
public function logChildProcessFinished(): void
5757
{
5858
// Do nothing.
5959
}
6060

61-
public function logUnexpectedOutput(string $buffer, string $progressSymbol): void
61+
public function logUnexpectedChildProcessOutput(string $buffer, string $progressSymbol): void
6262
{
6363
// Do nothing.
6464
}

src/Logger/StandardLogger.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function logConfiguration(
8585
$this->output->writeln('');
8686
}
8787

88-
public function startProgress(?int $numberOfItems): void
88+
public function logStart(?int $numberOfItems): void
8989
{
9090
Assert::false(
9191
isset($this->progressBar),
@@ -98,7 +98,7 @@ public function startProgress(?int $numberOfItems): void
9898
);
9999
}
100100

101-
public function advance(int $steps = 1): void
101+
public function logAdvance(int $steps = 1): void
102102
{
103103
Assert::true(
104104
isset($this->progressBar),
@@ -108,7 +108,7 @@ public function advance(int $steps = 1): void
108108
$this->progressBar->advance($steps);
109109
}
110110

111-
public function finish(string $itemName): void
111+
public function logFinish(string $itemName): void
112112
{
113113
Assert::true(
114114
isset($this->progressBar),
@@ -138,17 +138,17 @@ public function logItemProcessingFailed(string $item, Throwable $throwable): voi
138138
));
139139
}
140140

141-
public function logCommandStarted(string $commandName): void
141+
public function logChildProcessStarted(string $commandName): void
142142
{
143143
$this->logger->debug('Command started: '.$commandName);
144144
}
145145

146-
public function logCommandFinished(): void
146+
public function logChildProcessFinished(): void
147147
{
148148
$this->logger->debug('Command finished');
149149
}
150150

151-
public function logUnexpectedOutput(string $buffer, string $progressSymbol): void
151+
public function logUnexpectedChildProcessOutput(string $buffer, string $progressSymbol): void
152152
{
153153
$this->output->writeln('');
154154
$this->output->writeln(sprintf(

src/ParallelExecutor.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ private function executeMainProcess(
231231
$shouldSpawnChildProcesses,
232232
);
233233

234-
$logger->startProgress($numberOfItems);
234+
$logger->logStart($numberOfItems);
235235

236236
if ($shouldSpawnChildProcesses) {
237237
$exitCode = $this
@@ -248,11 +248,11 @@ private function executeMainProcess(
248248
$input,
249249
$output,
250250
$logger,
251-
static fn () => $logger->advance(),
251+
static fn () => $logger->logAdvance(),
252252
);
253253
}
254254

255-
$logger->finish($itemName);
255+
$logger->logFinish($itemName);
256256

257257
($this->runAfterLastCommand)($input, $output);
258258

@@ -372,10 +372,10 @@ private function processChildOutput(
372372

373373
// Display unexpected output
374374
if ($charactersCount !== mb_strlen($buffer)) {
375-
$logger->logUnexpectedOutput($buffer, $progressSymbol);
375+
$logger->logUnexpectedChildProcessOutput($buffer, $progressSymbol);
376376
}
377377

378-
$logger->advance($charactersCount);
378+
$logger->logAdvance($charactersCount);
379379
}
380380

381381
private static function validateBatchSize(int $batchSize): void

src/Process/SymfonyProcessLauncher.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ private function startProcess(InputStream $inputStream): void
163163
$this->callback,
164164
);
165165

166-
$this->logger->logCommandStarted($process->getCommandLine());
166+
$this->logger->logChildProcessStarted($process->getCommandLine());
167167

168168
$this->runningProcesses[] = $process;
169169
}
@@ -192,7 +192,7 @@ private function freeTerminatedProcesses(): int
192192
*/
193193
private function freeProcess(int $index, Process $process): int
194194
{
195-
$this->logger->logCommandFinished();
195+
$this->logger->logChildProcessFinished();
196196

197197
unset($this->runningProcesses[$index]);
198198

tests/Logger/DummyLogger.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@ public function logConfiguration(
3434
];
3535
}
3636

37-
public function startProgress(?int $numberOfItems): void
37+
public function logStart(?int $numberOfItems): void
3838
{
3939
$this->records[] = [
4040
__FUNCTION__,
4141
func_get_args(),
4242
];
4343
}
4444

45-
public function advance(int $steps = 1): void
45+
public function logAdvance(int $steps = 1): void
4646
{
4747
$this->records[] = [
4848
__FUNCTION__,
4949
func_get_args(),
5050
];
5151
}
5252

53-
public function finish(string $itemName): void
53+
public function logFinish(string $itemName): void
5454
{
5555
$this->records[] = [
5656
__FUNCTION__,
@@ -66,23 +66,23 @@ public function logItemProcessingFailed(string $item, Throwable $throwable): voi
6666
];
6767
}
6868

69-
public function logCommandStarted(string $commandName): void
69+
public function logChildProcessStarted(string $commandName): void
7070
{
7171
$this->records[] = [
7272
__FUNCTION__,
7373
func_get_args(),
7474
];
7575
}
7676

77-
public function logCommandFinished(): void
77+
public function logChildProcessFinished(): void
7878
{
7979
$this->records[] = [
8080
__FUNCTION__,
8181
func_get_args(),
8282
];
8383
}
8484

85-
public function logUnexpectedOutput(string $buffer, string $progressSymbol): void
85+
public function logUnexpectedChildProcessOutput(string $buffer, string $progressSymbol): void
8686
{
8787
$this->records[] = [
8888
__FUNCTION__,

tests/Logger/FakeLogger.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ public function logConfiguration(
2929
throw new DomainException('Unexpected call.');
3030
}
3131

32-
public function startProgress(?int $numberOfItems): void
32+
public function logStart(?int $numberOfItems): void
3333
{
3434
throw new DomainException('Unexpected call.');
3535
}
3636

37-
public function advance(int $steps = 1): void
37+
public function logAdvance(int $steps = 1): void
3838
{
3939
throw new DomainException('Unexpected call.');
4040
}
4141

42-
public function finish(string $itemName): void
42+
public function logFinish(string $itemName): void
4343
{
4444
throw new DomainException('Unexpected call.');
4545
}
@@ -49,17 +49,17 @@ public function logItemProcessingFailed(string $item, Throwable $throwable): voi
4949
throw new DomainException('Unexpected call.');
5050
}
5151

52-
public function logCommandStarted(string $commandName): void
52+
public function logChildProcessStarted(string $commandName): void
5353
{
5454
throw new DomainException('Unexpected call.');
5555
}
5656

57-
public function logCommandFinished(): void
57+
public function logChildProcessFinished(): void
5858
{
5959
throw new DomainException('Unexpected call.');
6060
}
6161

62-
public function logUnexpectedOutput(string $buffer, string $progressSymbol): void
62+
public function logUnexpectedChildProcessOutput(string $buffer, string $progressSymbol): void
6363
{
6464
throw new DomainException('Unexpected call.');
6565
}

tests/Logger/StandardLoggerTest.php

+19-19
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ private static function withChildConfigurationProvider(): iterable
342342

343343
public function test_it_can_log_the_start_of_the_processing(): void
344344
{
345-
$this->logger->startProgress(10);
345+
$this->logger->logStart(10);
346346

347347
$expected = <<<'TXT'
348348
0/10 [>---------------------------] 0%
@@ -353,20 +353,20 @@ public function test_it_can_log_the_start_of_the_processing(): void
353353

354354
public function test_it_cannot_start_an_already_started_process(): void
355355
{
356-
$this->logger->startProgress(10);
356+
$this->logger->logStart(10);
357357

358358
$this->expectException(InvalidArgumentException::class);
359359
$this->expectExceptionMessage('Cannot start the progress: already started.');
360360

361-
$this->logger->startProgress(10);
361+
$this->logger->logStart(10);
362362
}
363363

364364
public function test_it_can_log_the_progress_of_the_processing(): void
365365
{
366-
$this->logger->startProgress(10);
366+
$this->logger->logStart(10);
367367
$this->output->fetch();
368368

369-
$this->logger->advance();
369+
$this->logger->logAdvance();
370370

371371
$expected = <<<'TXT'
372372
@@ -381,15 +381,15 @@ public function test_it_cannot_advance_a_non_started_process(): void
381381
$this->expectException(InvalidArgumentException::class);
382382
$this->expectExceptionMessage('Expected the progress to be started.');
383383

384-
$this->logger->advance();
384+
$this->logger->logAdvance();
385385
}
386386

387387
public function test_it_can_log_the_progress_of_the_processing_of_multiple_items(): void
388388
{
389-
$this->logger->startProgress(10);
389+
$this->logger->logStart(10);
390390
$this->output->fetch();
391391

392-
$this->logger->advance(4);
392+
$this->logger->logAdvance(4);
393393

394394
$expected = <<<'TXT'
395395
@@ -401,10 +401,10 @@ public function test_it_can_log_the_progress_of_the_processing_of_multiple_items
401401

402402
public function test_it_can_log_the_end_of_the_processing(): void
403403
{
404-
$this->logger->startProgress(10);
404+
$this->logger->logStart(10);
405405
$this->output->fetch();
406406

407-
$this->logger->finish('tokens');
407+
$this->logger->logFinish('tokens');
408408

409409
$expected = <<<'TXT'
410410
@@ -422,16 +422,16 @@ public function test_it_cannot_end_the_processing_of_a_non_started_process(): vo
422422
$this->expectException(InvalidArgumentException::class);
423423
$this->expectExceptionMessage('Expected the progress to be started.');
424424

425-
$this->logger->finish('tokens');
425+
$this->logger->logFinish('tokens');
426426
}
427427

428428
public function test_it_can_log_the_unexpected_output_of_a_child_process(): void
429429
{
430-
$this->logger->startProgress(10);
431-
$this->logger->advance(4);
430+
$this->logger->logStart(10);
431+
$this->logger->logAdvance(4);
432432
$this->output->fetch();
433433

434-
$this->logger->logUnexpectedOutput(
434+
$this->logger->logUnexpectedChildProcessOutput(
435435
'An error occurred.',
436436
self::ADVANCEMENT_CHARACTER,
437437
);
@@ -449,11 +449,11 @@ public function test_it_can_log_the_unexpected_output_of_a_child_process(): void
449449

450450
public function test_it_removes_the_progress_character_of_the_unexpected_output_of_a_child_process(): void
451451
{
452-
$this->logger->startProgress(10);
453-
$this->logger->advance(4);
452+
$this->logger->logStart(10);
453+
$this->logger->logAdvance(4);
454454
$this->output->fetch();
455455

456-
$this->logger->logUnexpectedOutput(
456+
$this->logger->logUnexpectedChildProcessOutput(
457457
'An error'.self::ADVANCEMENT_CHARACTER.' occurred.',
458458
self::ADVANCEMENT_CHARACTER,
459459
);
@@ -473,7 +473,7 @@ public function test_it_can_log_the_start_of_a_command(): void
473473
{
474474
$this->output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
475475

476-
$this->logger->logCommandStarted('/path/to/bin/console foo:bar --child');
476+
$this->logger->logChildProcessStarted('/path/to/bin/console foo:bar --child');
477477

478478
$expected = <<<'TXT'
479479
[debug] Command started: /path/to/bin/console foo:bar --child
@@ -487,7 +487,7 @@ public function test_it_can_log_the_end_of_a_command(): void
487487
{
488488
$this->output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
489489

490-
$this->logger->logCommandFinished();
490+
$this->logger->logChildProcessFinished();
491491

492492
$expected = <<<'TXT'
493493
[debug] Command finished

0 commit comments

Comments
 (0)