Skip to content

Commit 11a2a2b

Browse files
committed
TASK: Reverse stdout log and improve styling
1 parent aab5a6d commit 11a2a2b

3 files changed

Lines changed: 35 additions & 22 deletions

File tree

Classes/Core/Infrastructure/ContentReleaseLogger.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ class ContentReleaseLogger
1919
*/
2020
protected $contentReleaseIdentifier;
2121

22-
/**
23-
* @var string
24-
*/
25-
protected $logPrefix = '';
22+
protected string $logPrefix = '';
23+
24+
protected ?RendererIdentifier $rendererIdentifier;
2625

2726
protected function __construct(OutputInterface $output, ContentReleaseIdentifier $contentReleaseIdentifier, ?RendererIdentifier $rendererIdentifier)
2827
{
@@ -47,30 +46,30 @@ public static function fromSymfonyOutput(OutputInterface $output, ContentRelease
4746
return new static($output, $contentReleaseIdentifier, null);
4847
}
4948

50-
public function debug($message, array $additionalPayload = []): void
49+
public function debug(string $message, array $additionalPayload = []): void
5150
{
52-
$this->logToOutput($message, $additionalPayload);
51+
$this->logToOutput('DEBUG', $message, $additionalPayload);
5352
}
5453

55-
public function info($message, array $additionalPayload = []): void
54+
public function info(string $message, array $additionalPayload = []): void
5655
{
57-
$this->logToOutput($message, $additionalPayload);
56+
$this->logToOutput('INFO', $message, $additionalPayload);
5857
}
5958

60-
public function warn($message, array $additionalPayload = []): void
59+
public function warn(string $message, array $additionalPayload = []): void
6160
{
62-
$this->logToOutput($message, $additionalPayload);
61+
$this->logToOutput('WARNING', $message, $additionalPayload);
6362
}
6463

65-
public function error($message, array $additionalPayload = []): void
64+
public function error(string $message, array $additionalPayload = []): void
6665
{
67-
$this->logToOutput($message, $additionalPayload);
66+
$this->logToOutput('ERROR', $message, $additionalPayload);
6867
}
6968

70-
protected function logToOutput($message, array $additionalPayload = []): void
69+
protected function logToOutput(string $level, string $message, array $additionalPayload = []): void
7170
{
7271
$formattedPayload = $additionalPayload ? json_encode($additionalPayload) : '';
73-
$this->output->writeln($this->logPrefix . $message . $formattedPayload);
72+
$this->output->writeln($this->logPrefix . $level . ': ' . $message . $formattedPayload);
7473
}
7574

7675
public function logException(\Exception $exception, string $message, array $additionalPayload)

Resources/Private/BackendFusion/Integration/Backend.Details.fusion

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Flowpack.DecoupledContentStore.BackendController.details = Neos.Fusion:Component
88
// - redisContentStores: array of all configured content store identifiers
99
// - isPrimary: bool
1010

11+
stdOutLines = ${Array.filter(String.pregSplit(String.htmlSpecialChars(jobLogs.stdout), "/\r\n|\n|\r/"))}
12+
1113
renderer = afx`
1214
<div id="app">
1315
<form id="postHelper" method="post">
@@ -38,13 +40,19 @@ Flowpack.DecoupledContentStore.BackendController.details = Neos.Fusion:Component
3840
/>
3941
</Neos.Fusion:Loop>
4042

41-
<h2 @if.isTrue={detailTaskName} class="text-3xl py-5">Log Output for {detailTaskName}</h2>
42-
<pre @if={!String.isBlank(jobLogs.stderr)} title="stderr" class="block whitespace-pre overflow-x-scroll border border-red-800 p-2 mb-6">
43-
{String.htmlSpecialChars(jobLogs.stderr)}
44-
</pre>
45-
<pre title="stdout" class="block whitespace-pre overflow-x-scroll">
46-
{String.htmlSpecialChars(jobLogs.stdout)}
47-
</pre>
43+
<div @if={!String.isBlank(jobLogs.stderr)}>
44+
<h2 class="text-3xl py-5">Error output for {detailTaskName}</h2>
45+
<pre title="stderr" class="block whitespace-pre overflow-x-scroll border border-red-800 p-2 mb-6">
46+
{String.htmlSpecialChars(jobLogs.stderr)}
47+
</pre>
48+
</div>
49+
50+
<h2 class="text-3xl py-5">Log output for {detailTaskName}</h2>
51+
<div title="stdout" class="stdout grid gap-2">
52+
<Neos.Fusion:Loop items={Array.reverse(props.stdOutLines)} iterationName="iteration">
53+
<pre>{Array.length(props.stdOutLines) - iteration.index}: {String.pregReplace(item, "/(DEBUG|WARNING|ERROR|INFO): (.*)/", "<span class=\"log-level-$1\">$1:</span> <span class=\"log-content-$1\">$2</span>")}</pre>
54+
</Neos.Fusion:Loop>
55+
</div>
4856
</Neos.Fusion:Fragment>
4957
<p @if.notData={!detailsData}>
5058
No data exists for this release in Redis.

Resources/Public/BackendCompiled/out.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* ../../../../../../../../../var/folders/jx/0n3dgdj52yd7lhy7jz8m_lyc0000gn/T/tmp-76784-4SF1kWZd2RxP/Flowpack.DecoupledContentStore/Resources/Private/Js/1705479026689-styles.css */
1+
/* ../../../../../../../../../var/folders/1z/rq1_kd710hn00r35j5rzqs5h0000gn/T/tmp-24630-ZfKI51gf2y1c/Flowpack.DecoupledContentStore/Resources/Private/Js/1705488391983-styles.css */
22
#app *,
33
#app ::before,
44
#app ::after {
@@ -70,6 +70,9 @@
7070
#app .table {
7171
display: table;
7272
}
73+
#app .grid {
74+
display: grid;
75+
}
7376
#app .hidden {
7477
display: none;
7578
}
@@ -117,6 +120,9 @@
117120
#app .justify-center {
118121
justify-content: center;
119122
}
123+
#app .gap-2 {
124+
gap: 0.5rem;
125+
}
120126
#app .divide-y > :not([hidden]) ~ :not([hidden]) {
121127
--tw-divide-y-reverse: 0;
122128
border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));

0 commit comments

Comments
 (0)