vendor/symfony/web-profiler-bundle/Resources/views/Collector/logger.html.twig line 183

Open in your IDE?
  1. {% extends '@WebProfiler/Profiler/layout.html.twig' %}
  2. {% import _self as helper %}
  3. {% block toolbar %}
  4.     {% if collector.counterrors or collector.countdeprecations or collector.countwarnings %}
  5.         {% set icon %}
  6.             {% set status_color = collector.counterrors ? 'red' : collector.countwarnings ? 'yellow' : 'none' %}
  7.             {{ include('@WebProfiler/Icon/logger.svg') }}
  8.             <span class="sf-toolbar-value">{{ collector.counterrors ?: (collector.countdeprecations + collector.countwarnings) }}</span>
  9.         {% endset %}
  10.         {% set text %}
  11.             <div class="sf-toolbar-info-piece">
  12.                 <b>Errors</b>
  13.                 <span class="sf-toolbar-status sf-toolbar-status-{{ collector.counterrors ? 'red' }}">{{ collector.counterrors|default(0) }}</span>
  14.             </div>
  15.             <div class="sf-toolbar-info-piece">
  16.                 <b>Warnings</b>
  17.                 <span class="sf-toolbar-status sf-toolbar-status-{{ collector.countwarnings ? 'yellow' }}">{{ collector.countwarnings|default(0) }}</span>
  18.             </div>
  19.             <div class="sf-toolbar-info-piece">
  20.                 <b>Deprecations</b>
  21.                 <span class="sf-toolbar-status sf-toolbar-status-{{ collector.countdeprecations ? 'none' }}">{{ collector.countdeprecations|default(0) }}</span>
  22.             </div>
  23.         {% endset %}
  24.         {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url, status: status_color }) }}
  25.     {% endif %}
  26. {% endblock %}
  27. {% block menu %}
  28.     <span class="label label-status-{{ collector.counterrors ? 'error' : collector.countwarnings ? 'warning' : 'none' }} {{ collector.logs is empty ? 'disabled' }}">
  29.         <span class="icon">{{ include('@WebProfiler/Icon/logger.svg') }}</span>
  30.         <strong>Logs</strong>
  31.         {% if collector.counterrors or collector.countdeprecations or collector.countwarnings %}
  32.             <span class="count">
  33.                 <span>{{ collector.counterrors ?: (collector.countdeprecations + collector.countwarnings) }}</span>
  34.             </span>
  35.         {% endif %}
  36.     </span>
  37. {% endblock %}
  38. {% block panel %}
  39.     <h2>Log Messages</h2>
  40.     {% if collector.processedLogs is empty %}
  41.         <div class="empty">
  42.             <p>No log messages available.</p>
  43.         </div>
  44.     {% else %}
  45.         {% set has_error_logs = collector.processedLogs|column('type')|filter(type => 'error' == type)|length > 0 %}
  46.         {% set has_deprecation_logs = collector.processedLogs|column('type')|filter(type => 'deprecation' == type)|length > 0 %}
  47.         {% set filters = collector.filters %}
  48.         <div class="log-filters">
  49.             <div id="log-filter-type" class="log-filter">
  50.                 <ul class="tab-navigation">
  51.                     <li class="{{ not has_error_logs and not has_deprecation_logs ? 'active' }}">
  52.                         <input {{ not has_error_logs and not has_deprecation_logs ? 'checked' }} type="radio" id="filter-log-type-all" name="filter-log-type" value="all">
  53.                         <label for="filter-log-type-all">All messages</label>
  54.                     </li>
  55.                     <li class="{{ has_error_logs ? 'active' }}">
  56.                         <input {{ has_error_logs ? 'checked' }} type="radio" id="filter-log-type-error" name="filter-log-type" value="error">
  57.                         <label for="filter-log-type-error">
  58.                             Errors
  59.                             <span class="badge status-{{ collector.counterrors ? 'error' }}">{{ collector.counterrors|default(0) }}</span>
  60.                         </label>
  61.                     </li>
  62.                     <li class="{{ not has_error_logs and has_deprecation_logs ? 'active' }}">
  63.                         <input {{ not has_error_logs and has_deprecation_logs ? 'checked' }} type="radio" id="filter-log-type-deprecation" name="filter-log-type" value="deprecation">
  64.                         <label for="filter-log-type-deprecation">
  65.                             Deprecations
  66.                             <span class="badge status-{{ collector.countdeprecations ? 'warning' }}">{{ collector.countdeprecations|default(0) }}</span>
  67.                         </label>
  68.                     </li>
  69.                 </ul>
  70.             </div>
  71.             <details id="log-filter-priority" class="log-filter">
  72.                 <summary>
  73.                     <span class="icon">{{ include('@WebProfiler/Icon/filter.svg') }}</span>
  74.                     Level (<span class="filter-active-num">{{ filters.priority|length - 1 }}</span>)
  75.                 </summary>
  76.                 <div class="log-filter-content">
  77.                     <div class="filter-select-all-or-none">
  78.                         <button type="button" class="btn btn-link select-all">Select All</button>
  79.                         <button type="button" class="btn btn-link select-none">Select None</button>
  80.                     </div>
  81.                     {% for label, value in filters.priority %}
  82.                         <div class="log-filter-option">
  83.                             <input {{ 'debug' != value ? 'checked' }} type="checkbox" id="filter-log-level-{{ value }}" name="filter-log-level-{{ value }}" value="{{ value }}">
  84.                             <label for="filter-log-level-{{ value }}">{{ label }}</label>
  85.                         </div>
  86.                     {% endfor %}
  87.                 </div>
  88.             </details>
  89.             <details id="log-filter-channel" class="log-filter">
  90.                 <summary>
  91.                     <span class="icon">{{ include('@WebProfiler/Icon/filter.svg') }}</span>
  92.                     Channel (<span class="filter-active-num">{{ filters.channel|length - 1 }}</span>)
  93.                 </summary>
  94.                 <div class="log-filter-content">
  95.                     <div class="filter-select-all-or-none">
  96.                         <button type="button" class="btn btn-link select-all">Select All</button>
  97.                         <button type="button" class="btn btn-link select-none">Select None</button>
  98.                     </div>
  99.                     {% for value in filters.channel %}
  100.                         <div class="log-filter-option">
  101.                             <input {{ 'event' != value ? 'checked' }} type="checkbox" id="filter-log-channel-{{ value }}" name="filter-log-channel-{{ value }}" value="{{ value }}">
  102.                             <label for="filter-log-channel-{{ value }}">{{ value|title }}</label>
  103.                         </div>
  104.                     {% endfor %}
  105.                 </div>
  106.             </details>
  107.         </div>
  108.         <table class="logs">
  109.             <colgroup>
  110.                 <col width="140px">
  111.                 <col>
  112.             </colgroup>
  113.             <thead>
  114.                 <tr>
  115.                     <th>Time</th>
  116.                     <th>Message</th>
  117.                 </tr>
  118.             </thead>
  119.             <tbody>
  120.                 {% for log in collector.processedLogs %}
  121.                     {% set css_class = 'error' == log.type ? 'error'
  122.                         : (log.priorityName == 'WARNING' or 'deprecation' == log.type) ? 'warning'
  123.                         : 'silenced' == log.type ? 'silenced'
  124.                     %}
  125.                     <tr class="log-status-{{ css_class }}" data-type="{{ log.type }}" data-priority="{{ log.priority }}" data-channel="{{ log.channel }}" style="{{ 'event' == log.channel or 'DEBUG' == log.priorityName ? 'display: none' }}">
  126.                         <td class="log-timestamp">
  127.                             <time title="{{ log.timestamp|date('r') }}" datetime="{{ log.timestamp|date('c') }}">
  128.                                 {{ log.timestamp|date('H:i:s.v') }}
  129.                             </time>
  130.                             {% if log.type in ['error', 'deprecation', 'silenced'] or 'WARNING' == log.priorityName %}
  131.                                 <span class="log-type-badge badge badge-{{ css_class }}">
  132.                                     {% if 'error' == log.type or 'WARNING' == log.priorityName %}
  133.                                         {{ log.priorityName|lower }}
  134.                                     {% else %}
  135.                                         {{ log.type|lower }}
  136.                                     {% endif %}
  137.                                 </span>
  138.                             {% else %}
  139.                                 <span class="log-type-badge badge badge-{{ css_class }}">
  140.                                     {{ log.priorityName|lower }}
  141.                                 </span>
  142.                             {% endif %}
  143.                         </td>
  144.                         <td class="font-normal">
  145.                             {{ helper.render_log_message('debug', loop.index, log) }}
  146.                         </td>
  147.                     </tr>
  148.                 {% endfor %}
  149.             </tbody>
  150.         </table>
  151.         <div class="no-logs-message empty">
  152.             <p>There are no log messages.</p>
  153.         </div>
  154.         <script>Sfjs.initializeLogsTable();</script>
  155.     {% endif %}
  156.     {% set compilerLogTotal = 0 %}
  157.     {% for logs in collector.compilerLogs %}
  158.         {% set compilerLogTotal = compilerLogTotal + logs|length %}
  159.     {% endfor %}
  160.     <details class="container-compilation-logs">
  161.         <summary>
  162.             <h4>Container Compilation Logs <span class="text-muted">({{ compilerLogTotal }})</span></h4>
  163.             <span class="text-muted">Log messages generated during the compilation of the service container.</span>
  164.         </summary>
  165.         {% if collector.compilerLogs is empty %}
  166.             <div class="empty">
  167.                 <p>There are no compiler log messages.</p>
  168.             </div>
  169.         {% else %}
  170.             <table class="container-logs">
  171.                 <thead>
  172.                 <tr>
  173.                     <th>Messages</th>
  174.                     <th class="full-width">Class</th>
  175.                 </tr>
  176.                 </thead>
  177.                 <tbody>
  178.                 {% for class, logs in collector.compilerLogs %}
  179.                     <tr>
  180.                         <td class="font-normal text-right">{{ logs|length }}</td>
  181.                         <td class="font-normal">
  182.                             {% set context_id = 'context-compiler-' ~ loop.index %}
  183.                             <button type="button" class="btn btn-link sf-toggle" data-toggle-selector="#{{ context_id }}" data-toggle-alt-content="{{ class }}">{{ class }}</button>
  184.                             <div id="{{ context_id }}" class="context sf-toggle-content sf-toggle-hidden">
  185.                                 <ul class="break-long-words">
  186.                                     {% for log in logs %}
  187.                                         <li>{{ profiler_dump_log(log.message) }}</li>
  188.                                     {% endfor %}
  189.                                 </ul>
  190.                             </div>
  191.                         </td>
  192.                     </tr>
  193.                 {% endfor %}
  194.                 </tbody>
  195.             </table>
  196.         {% endif %}
  197.     </details>
  198. {% endblock %}
  199. {% macro render_log_message(category, log_index, log) %}
  200.     {% set has_context = log.context is defined and log.context is not empty %}
  201.     {% set has_trace = log.context.exception.trace is defined %}
  202.     {% if not has_context %}
  203.         {{ profiler_dump_log(log.message) }}
  204.     {% else %}
  205.         {{ profiler_dump_log(log.message, log.context) }}
  206.     {% endif %}
  207.     <div class="log-metadata">
  208.         {% if log.channel %}
  209.             <span class="badge">{{ log.channel }}</span>
  210.         {% endif %}
  211.         {% if log.errorCount is defined and log.errorCount > 1 %}
  212.             <span class="log-num-occurrences">{{ log.errorCount }} times</span>
  213.         {% endif %}
  214.         {% if has_context %}
  215.             {% set context_id = 'context-' ~ category ~ '-' ~ log_index %}
  216.             <span><button type="button" class="btn btn-link text-small sf-toggle" data-toggle-selector="#{{ context_id }}" data-toggle-alt-content="Hide context">Show context</button></span>
  217.         {% endif %}
  218.         {% if has_trace %}
  219.             {% set trace_id = 'trace-' ~ category ~ '-' ~ log_index %}
  220.             <span><button type="button" class="btn btn-link text-small sf-toggle" data-toggle-selector="#{{ trace_id }}" data-toggle-alt-content="Hide trace">Show trace</button></span>
  221.         {% endif %}
  222.         {% if has_context %}
  223.             <div id="{{ context_id }}" class="context sf-toggle-content sf-toggle-hidden">
  224.                 {{ profiler_dump(log.context, maxDepth=1) }}
  225.             </div>
  226.         {% endif %}
  227.         {% if has_trace %}
  228.             <div id="{{ trace_id }}" class="context sf-toggle-content sf-toggle-hidden">
  229.                 {{ profiler_dump(log.context.exception.trace, maxDepth=1) }}
  230.             </div>
  231.         {% endif %}
  232.     </div>
  233. {% endmacro %}