Skip to content

Added basic viewer for event log details#1482

Open
jaxwilko wants to merge 2 commits intodevelopfrom
fix/log-viewer-details-missing
Open

Added basic viewer for event log details#1482
jaxwilko wants to merge 2 commits intodevelopfrom
fix/log-viewer-details-missing

Conversation

@jaxwilko
Copy link
Copy Markdown
Member

@jaxwilko jaxwilko commented May 6, 2026

This PR adds a very basic viewer for event log details.

image

Should resolve #1475.

I'd like to add better support for the new log viewer, but don't have time currently. To anybody reading this you can use:

$message = 'My Error Message';
$details = (new EventLog())->getDetails(new \Exception());
$details['exception']['message'] = $message;
$details['exception']['snippet'] = [
    'Something terrible has happened',
];

Log::error($message, $details);

To force in custom logs in the new style with fancy stack traces, but use at your own risk because it's fairly easy to break the renderer while doing this.

image

Summary by CodeRabbit

  • Bug Fixes
    • Event Logs field details now include a visible "DETAILS" block displaying the field value when available, providing more contextual information directly in the Event Logs view. No other behavior was changed.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Walkthrough

The change updates modules/system/controllers/eventlogs/_field_details.php: inside the logVersion !== 2 guard, it adds a conditional that, when $value is truthy, prints a DETAILS block containing the $value (using print_r) before the existing return path.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Added basic viewer for event log details' directly describes the main change: adding a viewer feature for event log details, which aligns with the changeset modifications.
Linked Issues check ✅ Passed The PR adds a DETAILS block to display contextual data in event log entries, directly addressing issue #1475's requirement to show contextual arrays in the backend Event Log interface.
Out of Scope Changes check ✅ Passed All changes in the PR are scoped to displaying event log details within the logVersion guard, directly supporting the linked issue objective without unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/log-viewer-details-missing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@LukeTowers LukeTowers added this to the 1.2.13 milestone May 6, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
modules/system/controllers/eventlogs/_field_details.php (1)

5-5: ⚡ Quick win

Hardcoded DETAILS label bypasses i18n

<h4>DETAILS</h4> is a raw English string. Every other visible label in this file uses e(trans('system::lang.event_log.details.*')). This label should go through the same pipeline, both for consistency and to support localization.

♻️ Proposed fix
-            '<h4>DETAILS</h4><pre style="background: `#fff`; padding: 10px; border: 1px solid `#ddd`;">%s</pre>',
+            '<h4>%s</h4><pre style="background: `#fff`; padding: 10px; border: 1px solid `#ddd`;">%s</pre>',
+            e(trans('system::lang.event_log.details.details')),

Add the corresponding key to the language file(s):

// modules/system/lang/en/lang.php  (and other locales)
'details' => 'Details',
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@modules/system/controllers/eventlogs/_field_details.php` at line 5, Replace
the hardcoded "<h4>DETAILS</h4>" with a translatable call consistent with the
rest of the file (e.g. use e(trans('system::lang.event_log.details.title')) or
the existing event_log.details namespace) and add the corresponding key/value
("Details") to the language files (modules/system/lang/en/lang.php and other
locales) so the label flows through the i18n pipeline like the other labels in
this file.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@modules/system/controllers/eventlogs/_field_details.php`:
- Around line 3-8: The DETAILS block currently renders print_r($value, true)
raw, causing stored XSS; change it to escape the rendered string before output
(e.g., wrap the print_r result with the template's escaping helper such as e()
or htmlspecialchars) in the printf call so the output is safely HTML-encoded;
update the printf invocation that prints the DETAILS preformatted block (the
block using printf and print_r) to pass an escaped string instead of the raw
print_r output.

---

Nitpick comments:
In `@modules/system/controllers/eventlogs/_field_details.php`:
- Line 5: Replace the hardcoded "<h4>DETAILS</h4>" with a translatable call
consistent with the rest of the file (e.g. use
e(trans('system::lang.event_log.details.title')) or the existing
event_log.details namespace) and add the corresponding key/value ("Details") to
the language files (modules/system/lang/en/lang.php and other locales) so the
label flows through the i18n pipeline like the other labels in this file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e811d3d9-bac4-4f04-afad-666a60c82ec0

📥 Commits

Reviewing files that changed from the base of the PR and between 0758670 and 46224b5.

📒 Files selected for processing (1)
  • modules/system/controllers/eventlogs/_field_details.php

Comment thread modules/system/controllers/eventlogs/_field_details.php
Comment thread modules/system/controllers/eventlogs/_field_details.php Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
modules/system/controllers/eventlogs/_field_details.php (1)

4-7: 💤 Low value

Inline styles on <pre> diverge from the existing <style> block convention.

The rest of the template centralises all presentation in the <style> block at line 105. Moving the new <pre> styles there keeps the stylesheet consistent and makes future theming changes easier.

♻️ Proposed refactor

Add to the <style> block (around line 105):

+    `#winter-log-viewer` pre.details-dump {
+        background: `#fff`;
+        padding: 10px;
+        border: 1px solid `#ddd`;
+    }

Update the printf call:

-            '<h4>DETAILS</h4><pre style="background: `#fff`; padding: 10px; border: 1px solid `#ddd`;">%s</pre>',
+            '<h4>DETAILS</h4><pre class="details-dump">%s</pre>',
             e(print_r($value, true))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@modules/system/controllers/eventlogs/_field_details.php` around lines 4 - 7,
The inline styles on the <pre> element should be moved into the existing
stylesheet and the HTML updated to use a class; add a new CSS rule in the
template's <style> block (matching the existing convention) for a selector like
.eventlog-details pre (or .details-pre) to include background, padding and
border, then modify the printf call that prints e(print_r($value, true)) to
output <pre class="...">%s</pre> instead of the inline style so presentation is
centralized.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@modules/system/controllers/eventlogs/_field_details.php`:
- Line 5: The template contains a hardcoded heading string '<h4>DETAILS</h4><pre
style="background: `#fff`; padding: 10px; border: 1px solid `#ddd`;">%s</pre>' which
bypasses i18n; replace the '<h4>DETAILS</h4>' fragment with a translated call
(use e(trans(...)) consistent with the rest of the file) referencing a new
language key such as 'event_log.details' and add the corresponding 'details' =>
'Details' entry under the event_log (or module-specific) array in the language
files so non-English backends receive the translated heading.

---

Nitpick comments:
In `@modules/system/controllers/eventlogs/_field_details.php`:
- Around line 4-7: The inline styles on the <pre> element should be moved into
the existing stylesheet and the HTML updated to use a class; add a new CSS rule
in the template's <style> block (matching the existing convention) for a
selector like .eventlog-details pre (or .details-pre) to include background,
padding and border, then modify the printf call that prints e(print_r($value,
true)) to output <pre class="...">%s</pre> instead of the inline style so
presentation is centralized.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 87ac5ed3-5961-4840-b831-8b1397433018

📥 Commits

Reviewing files that changed from the base of the PR and between 46224b5 and 0d37e79.

📒 Files selected for processing (1)
  • modules/system/controllers/eventlogs/_field_details.php

if (!isset($value['logVersion']) || $value['logVersion'] !== 2) {
if ($value ?? false) {
printf(
'<h4>DETAILS</h4><pre style="background: #fff; padding: 10px; border: 1px solid #ddd;">%s</pre>',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Hardcoded DETAILS label bypasses i18n.

Every other user-visible string in this template goes through trans()/e(trans(...)). The new <h4>DETAILS</h4> heading is the only hardcoded English label, which will break non-English backends.

🌐 Proposed fix
-            '<h4>DETAILS</h4><pre style="background: `#fff`; padding: 10px; border: 1px solid `#ddd`;">%s</pre>',
+            '<h4>%s</h4><pre style="background: `#fff`; padding: 10px; border: 1px solid `#ddd`;">%s</pre>',
+            e(trans('system::lang.event_log.details.details')),
             e(print_r($value, true))

Add the corresponding translation key to the language files, e.g.:

// modules/system/lang/en/lang.php  (under event_log.details)
'details' => 'Details',
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@modules/system/controllers/eventlogs/_field_details.php` at line 5, The
template contains a hardcoded heading string '<h4>DETAILS</h4><pre
style="background: `#fff`; padding: 10px; border: 1px solid `#ddd`;">%s</pre>' which
bypasses i18n; replace the '<h4>DETAILS</h4>' fragment with a translated call
(use e(trans(...)) consistent with the rest of the file) referencing a new
language key such as 'event_log.details' and add the corresponding 'details' =>
'Details' entry under the event_log (or module-specific) array in the language
files so non-English backends receive the translated heading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Contextual data array not displayed in backend Event Log despite documentation

2 participants