grav-plugin-admin icon indicating copy to clipboard operation
grav-plugin-admin copied to clipboard

Grav System Log Output date

Open teixeiradacunha opened this issue 2 months ago • 3 comments

The application event log (Grav System Log Output) is showing an issue: all entries display the same date, which always corresponds to the most recent event.

Image

teixeiradacunha avatar Oct 07 '25 23:10 teixeiradacunha

The problem was reproducible for me with Grav 1.8.0-beta.28. Grav uses the Monolog logger and the datetime format was changed https://github.com/Seldaek/monolog/commit/45b5e0e33e5b95f82d7b99b304ae20ff26e31f3f this could be the reason.

To resolve it I changed:

https://github.com/getgrav/grav/blob/7a6b8a90d454dbc42396e6be84700a61297076a0/system/src/Grav/Common/Helpers/LogViewer.php#L142-L144

to:

    try {
        $date = new DateTime($data['date']);
    } catch (DateMalformedStringException $e)  {
        $date = null;
    }
    
    return [
        'date' => $date,

This covers the new datetime formats e.g. "2025-12-09T17:34:36.059771+01:00" and the old format e.g. "2025-12-09 03:00:13"

I also changed:

https://github.com/getgrav/grav-plugin-admin/blob/1ec8fabc791216081a8987d2850888a2e3ca2af2/themes/grav/templates/partials/tools-logs.html.twig#L56

to:

<td class="date" title="{{ log.date|date('r') }}">{{ log.date|date('D, d M Y H:i:s') }}</td>

Xoriander avatar Dec 09 '25 16:12 Xoriander

Thanks for tracking this down. Why not create a PR and you'll get credit for the fix and make my life easier :)

rhukster avatar Dec 09 '25 16:12 rhukster

If it's easier, I can make a pull request tomorrow.

Xoriander avatar Dec 09 '25 16:12 Xoriander