winter icon indicating copy to clipboard operation
winter copied to clipboard

Add contextual information to event log

Open zaxbux opened this issue 3 years ago • 6 comments

In the logging docs, it says that contextual data can be included with the log entry:

Logs

Contextual information

An array of contextual data may also be passed to the log methods. This contextual data will be formatted and displayed with the log message:

Log::info('User failed to login.', ['id' => $user->id]);

This PR adds $event->context to the EventLog::add() call so that the context data is stored in the details column in the system_event_logs table.

zaxbux avatar Apr 24 '22 19:04 zaxbux

@zaxbux any ideas for how we can display this contextual data in the backend event logs view?

LukeTowers avatar Apr 29 '22 01:04 LukeTowers

Maybe pretty-printing JSON or by using Symfony\Component\VarDumper\Dumper\HtmlDumper for example:

backend-log-context

That screenshot is of a somewhat crude implementation that required changes to JS and CSS, although there's probably a more elegant solution.

zaxbux avatar Apr 30 '22 07:04 zaxbux

@zaxbux a simple dump($context) should be fine, it can always be improved upon later.

LukeTowers avatar May 02 '22 20:05 LukeTowers

@zaxbux are you still interested in this?

LukeTowers avatar Jul 15 '22 05:07 LukeTowers

Admittedly, I forgot to commit my changes back in May.

zaxbux avatar Jul 16 '22 18:07 zaxbux

@zaxbux so what does this PR look like now? Do you have a screenshot you can share?

LukeTowers avatar Jul 17 '22 17:07 LukeTowers

This pull request will be closed and archived in 3 days, as there has been no activity in this pull request for the last 6 months. If you intend to continue working on this pull request, please respond within 3 days. If this pull request is critical for your business, please reach out to us at [email protected].

github-actions[bot] avatar Mar 14 '23 00:03 github-actions[bot]