samsonasik / ErrorHeroModule

:gem: A Hero for your Zend Framework/Laminas, and Expressive/Mezzio application to log ( DB and Mail ) and handle php errors & exceptions during Mvc process/between request and response
MIT License
50 stars 7 forks source link

Wrong format of timestamp #41

Closed VadimIzmalkov closed 6 years ago

VadimIzmalkov commented 6 years ago

What ZF application I'm using when issue happen ?

What PHP version you're using?

What ErrorHeroModule version you're using?

Expected behavior

Write logs to database.

Actual behavior

Nothing happens in database once bug has been occured.

Explanation

Method $this->getDateTimeFormat() https://github.com/samsonasik/ErrorHeroModule/blob/master/src/Handler/Formatter/Json.php#L26 return timestamp in "c" format 2004-02-12T15:19:21+00:00 . On my preset Mysql requires "Y-m-d H:i:s"

Workaround

Change type of 'date' to text

samsonasik commented 6 years ago

In that case, you can setup your log config to set "formatter"'s dateTimeFormat with the following under "options" in db writers config:

// config/autoload/error-hero-module.local.php
    'log' => [
        'ErrorHeroModuleLogger' => [
            'writers' => [

                [
                    'name' => 'db',
                    'options' => [
                        // ... current config
                        'formatter' => [
                             'name' => 'db',
                             'options' => [
                                  'dateTimeFormat' => 'Y-m-d H:i:s',
                             ],
                         ],
                      // ...
                    ],
                ],

            ],
        ],
    ],
VadimIzmalkov commented 6 years ago

Thanks, it works for me