8000 feature #21502 Persist app bootstrapping logs for logger datacollecto… · ostrolucky/symfony@7c8f741 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7c8f741

Browse files
committed
feature symfony#21502 Persist app bootstrapping logs for logger datacollector (ScullWM, nicolas-grekas)
This PR was merged into the 3.3-dev branch. Discussion ---------- Persist app bootstrapping logs for logger datacollector | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | no | New feature? | yes | BC breaks? | ? | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#21405 | License | MIT Logs generated during the container build are catched by the BufferingLogger with a special flag. They are persist by the LoggerDataCollector and are available in the logger profiler. In the profiler toolbar, the "container build" logs increment the current logs counter (even if the container was previously built). <img width="540" alt="capture d ecran 2017-02-01 a 20 56 40" src="https://cloud.githubusercontent.com/assets/1017746/22523826/0bc12e4a-e8c1-11e6-830f-7f6238ea7423.png"> <img width="1022" alt="capture d ecran 2017-02-01 a 20 57 55" src="https://cloud.githubusercontent.com/assets/1017746/22523859/2c48a698-e8c1-11e6-9bdb-d85f3e692938.png"> The BufferingLogger now require the cachePath and the filesystem to persist a (unique) container build logs. If the current workflow is ok, I will update the test coverage (actually they fail). Maybe we can display the appDevDebugProjectContainerCompiler.log content in that logger profile. Commits ------- 2fd18b5 [VarDumper] Fine tune dumping log messages ce3ef6a Persist app bootstrapping logs for logger datacollector
2 parents 8ef8b13 + 4db8fa0 commit 7c8f741

File tree

3 files changed

+57
-9
lines changed

3 files changed

+57
-9
lines changed

Resources/views/Collector/logger.html.twig

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,52 @@
124124
</div>
125125
</div>
126126

127+
{% set compilerLogTotal = 0 %}
128+
{% for logs in collector.compilerLogs %}
129+
{% set compilerLogTotal = compilerLogTotal + logs|length %}
130+
{% endfor %}
131+
<div class="tab">
132+
<h3 class="tab-title">Container Compilation<span class="badge">{{ compilerLogTotal }}</span></h3>
133+
134+
<div class="tab-content">
135+
{% if collector.compilerLogs is empty %}
136+
<div class="empty">
137+
<p>There are no compiler log messages.</p>
138+
</div>
139+
{% else %}
140+
<table class="logs">
141+
<thead>
142+
<tr>
143+
<th class="full-width">Class</th>
144+
<th>Messages</th>
145+
</tr>
146+
</thead>
147+
148+
<tbody>
149+
{% for class, logs in collector.compilerLogs %}
150+
<tr class="">
151+
<td class="font-normal">
152+
{% set context_id = 'context-compiler-' ~ loop.index %}
153+
154+
<a class="btn btn-link sf-toggle" data-toggle-selector="#{{ context_id }}" data-toggle-alt-content="{{ class }}">{{ class }}</a>
155+
156+
<div id="{{ context_id }}" class="context sf-toggle-content sf-toggle-hidden">
157+
<ul>
158+
{% for log in logs %}
159+
<li>{{ profiler_dump_log(log.message) }}</li>
160+
{% endfor %}
161+
</ul>
162+
</div>
163+
</td>
164+
<td class="font-normal text-right">{{ logs|length }}</td>
165+
</tr>
166+
{% endfor %}
167+
</tbody>
168+
</table>
169+
{% endif %}
170+
</div>
171+
</div>
172+
127173
</div>
128174
{% endif %}
129175
{% endblock %}
@@ -165,24 +211,24 @@
165211

166212
{% endif %}
167213

168-
<td class="font-normal">{{ helper.render_log_message(category, loop.index, log, is_deprecation) }}</td>
214+
<td class="font-normal">{{ helper.render_log_message(category, loop.index, log) }}</td>
169215
</tr>
170216
{% endfor %}
171217
</tbody>
172218
</table>
173219
{% endmacro %}
174220

175-
{% macro render_log_message(category, log_index, log, is_deprecation = false) %}
176-
{% if is_deprecation %}
177-
{{ log.message }}
221+
{% macro render_log_message(category, log_index, log) %}
222+
{% if log.context.exception.trace is defined %}
223+
{{ profiler_dump_log(log.message, log.context) }}
178224

179225
{% set context_id = 'context-' ~ category ~ '-' ~ log_index %}
180226

181227
<span class="metadata">
182228
<a class="btn btn-link text-small sf-toggle" data-toggle-selector="#{{ context_id }}" data-toggle-alt-content="Hide trace">Show trace</a>
183229

184230
<div id="{{ context_id }}" class="context sf-toggle-content sf-toggle-hidden">
185-
{{ profiler_dump(log.context.exception['\0Exception\0trace'], maxDepth=2) }}
231+
{{ profiler_dump(log.context.exception.trace, maxDepth=1) }}
186232
</div>
187233
</span>
188234
{% elseif log.context is defined and log.context is not empty %}
@@ -198,6 +244,6 @@
198244
</div>
199245
</span>
200246
{% else %}
201-
{{ log.message }}
247+
{{ profiler_dump_log(log.message) }}
202248
{% endif %}
203249
{% endmacro %}

Resources/views/Profiler/profiler.css.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ table.logs .metadata {
913913
#collector-content .sf-dump-key { color: #789339; }
914914
#collector-content .sf-dump-ref { color: #6E6E6E; }
915915
#collector-content .sf-dump-ellipsis { color: #CC7832; max-width: 100em; }
916+
#collector-content .sf-dump-ellipsis-path { max-width: 5em; }
916917

917918
#collector-content .sf-dump {
918919
margin: 0;

Twig/WebProfilerExtension.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,19 @@ public function dumpData(\Twig_Environment $env, Data $data, $maxDepth = 0)
8989
return str_replace("\n</pre", '</pre', rtrim($dump));
9090
}
9191

92-
public function dumpLog(\Twig_Environment $env, $message, Data $context)
92+
public function dumpLog(\Twig_Environment $env, $message, Data $context = null)
9393
{
9494
$message = twig_escape_filter($env, $message);
95+
$message = preg_replace('/&quot;(.*?)&quot;/', '&quot;<b>$1</b>&quot;', $message);
9596

96-
if (false === strpos($message, '{')) {
97+
if (null === $context || false === strpos($message, '{')) {
9798
return '<span class="dump-inline">'.$message.'</span>';
9899
}
99100

100101
$replacements = array();
101102
foreach ($context as $k => $v) {
102103
$k = '{'.twig_escape_filter($env, $k).'}';
103-
$replacements['&quot;'.$k.'&quot;'] = $replacements[$k] = $this->dumpData($env, $v);
104+
$replacements['&quot;<b>'.$k.'</b>&quot;'] = $replacements['&quot;'.$k.'&quot;'] = $replacements[$k] = $this->dumpData($env, $v);
104105
}
105106

106107
return '<span class="dump-inline">'.strtr($message, $replacements).'</span>';

0 commit comments

Comments
 (0)
0