Skip to content

Commit 71a4ac5

Browse files
authored
Merge pull request #36 from Flowpack/bugfix/joblogs-preserve-whitespace-and-highlight-error
BUGFIX: Joblogs preserve whitespace and highlight errors
2 parents 53db941 + 11a2a2b commit 71a4ac5

3 files changed

Lines changed: 54 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>
43-
{String.nl2br(String.htmlSpecialChars(jobLogs.stderr))}
44-
</pre>
45-
<pre>
46-
{String.nl2br(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: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* ../../../../../../../../../var/folders/1z/rq1_kd710hn00r35j5rzqs5h0000gn/T/tmp-53849-7B7Y00uLTAH0/Flowpack.DecoupledContentStore/Resources/Private/Js/1674136282935-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 {
@@ -34,6 +34,9 @@
3434
margin-top: 1.25rem;
3535
margin-bottom: 1.25rem;
3636
}
37+
#app .mb-6 {
38+
margin-bottom: 1.5rem;
39+
}
3740
#app .mt-4 {
3841
margin-top: 1rem;
3942
}
@@ -49,6 +52,9 @@
4952
#app .mb-2 {
5053
margin-bottom: 0.5rem;
5154
}
55+
#app .block {
56+
display: block;
57+
}
5258
#app .inline-block {
5359
display: inline-block;
5460
}
@@ -64,6 +70,9 @@
6470
#app .table {
6571
display: table;
6672
}
73+
#app .grid {
74+
display: grid;
75+
}
6776
#app .hidden {
6877
display: none;
6978
}
@@ -111,6 +120,9 @@
111120
#app .justify-center {
112121
justify-content: center;
113122
}
123+
#app .gap-2 {
124+
gap: 0.5rem;
125+
}
114126
#app .divide-y > :not([hidden]) ~ :not([hidden]) {
115127
--tw-divide-y-reverse: 0;
116128
border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
@@ -123,11 +135,17 @@
123135
#app .overflow-hidden {
124136
overflow: hidden;
125137
}
138+
#app .overflow-x-scroll {
139+
overflow-x: scroll;
140+
}
126141
#app .truncate {
127142
overflow: hidden;
128143
text-overflow: ellipsis;
129144
white-space: nowrap;
130145
}
146+
#app .whitespace-pre {
147+
white-space: pre;
148+
}
131149
#app .rounded-md {
132150
border-radius: 0.375rem;
133151
}
@@ -143,6 +161,10 @@
143161
#app .border-2 {
144162
border-width: 2px;
145163
}
164+
#app .border-red-800 {
165+
--tw-border-opacity: 1;
166+
border-color: rgb(153 27 27 / var(--tw-border-opacity));
167+
}
146168
#app .border-gray-300 {
147169
--tw-border-opacity: 1;
148170
border-color: rgb(209 213 219 / var(--tw-border-opacity));
@@ -191,6 +213,9 @@
191213
--tw-bg-opacity: 1;
192214
background-color: rgb(147 197 253 / var(--tw-bg-opacity));
193215
}
216+
#app .p-2 {
217+
padding: 0.5rem;
218+
}
194219
#app .py-5 {
195220
padding-top: 1.25rem;
196221
padding-bottom: 1.25rem;

0 commit comments

Comments
 (0)