Skip to content

Commit

Permalink
feat(Log): Add extra line for line/debug
Browse files Browse the repository at this point in the history
  • Loading branch information
pionl committed May 4, 2023
1 parent 8bc0bca commit 07ea6d0
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/Log/Handlers/ConsoleOutputHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use LaraStrict\Log\Managers\ConsoleOutputManager;
use Monolog\Handler\AbstractProcessingHandler;
use Monolog\Logger;
use Symfony\Component\Console\Output\OutputInterface;

/**
* @internal
Expand All @@ -32,6 +33,8 @@ protected function write(array $record): void
return;
}

$context = $record['context'];
$hasContext = $context !== [];
$message = $record['message'];

switch ($record['level']) {
Expand All @@ -51,15 +54,11 @@ protected function write(array $record): void
$consoleOutputFactory->error($message);
break;
default:
$outputStyle->newLine();
$outputStyle->write(messages: ' <options=bold>' . $message . '</>');
$outputStyle->newLine();
$this->writeLine(outputStyle: $outputStyle, message: $message, hasContext: $hasContext);
break;
}

$context = $record['context'];

if ($context !== []) {
if ($hasContext) {
foreach ($context as $line => $value) {
$isGenericValue = is_string($value) || is_int($value) || is_float($value) || is_bool($value);

Expand All @@ -77,4 +76,15 @@ protected function write(array $record): void
$outputStyle->newLine();
}
}

protected function writeLine(OutputStyle $outputStyle, mixed $message, bool $hasContext): void
{
$outputStyle->newLine();
$outputStyle->write(messages: ' <options=bold>' . $message . '</>');
$outputStyle->newLine();

if ($hasContext === false) {
$outputStyle->newLine();
}
}
}

0 comments on commit 07ea6d0

Please sign in to comment.