|
I recently submitted a PR for a MongoDB log writer
(#1825<https://github.com/zendframework/zf2/pull/1825> ). Therein, I had a discussion with Maks over the structure of the $event argument received by the writer's write() method, and I was pointed to the invocation in Zend/Log/Logger.php<https://github.com/zendframework/zf2/blob/master/library/Zend/Log/Logger.php#L285>. Currently, the Logger converts the current date to a string via a configured format option and then passes this string on to the writer. This is undesirable for DB-based writers, which lose the ability to store the timestamp in a native date type. As I mention in the PR comments, the Logger format string could be "month-day", which makes conversion back to a timestamp impossible. I noticed that the DB writer doesn't support a formatter service (evidently used to convert $event arrays into single strings). In place of the formatter, the DB writer has its own logic to map $event keys to columns. I would like to propose pushing the responsibility of date formatting over to the formatter services. Existing formatter classes can take a date format option (instead of the Logger), and the $event argument for writers can include the actual DateTime instead of a timestamp string. -- jeremy mikola |
|
Administrator
|
-- Jeremy Mikola <[hidden email]> wrote
(on Tuesday, 10 July 2012, 04:36 PM -0400): > I recently submitted a PR for a MongoDB log writer > (#1825<https://github.com/zendframework/zf2/pull/1825> > ). > > Therein, I had a discussion with Maks over the structure of the $event > argument received by the writer's write() method, and I was pointed to the > invocation in Zend/Log/Logger.php<https://github.com/zendframework/zf2/blob/master/library/Zend/Log/Logger.php#L285>. > Currently, the Logger converts the current date to a string via a > configured format option and then passes this string on to the writer. > > This is undesirable for DB-based writers, which lose the ability to store > the timestamp in a native date type. As I mention in the PR comments, the > Logger format string could be "month-day", which makes conversion back to a > timestamp impossible. I noticed that the DB writer doesn't support a > formatter service (evidently used to convert $event arrays into single > strings). In place of the formatter, the DB writer has its own logic to map > $event keys to columns. > > I would like to propose pushing the responsibility of date formatting over > to the formatter services. Existing formatter classes can take a date > format option (instead of the Logger), and the $event argument for writers > can include the actual DateTime instead of a timestamp string. Sounds good to me. :) BTW, zf-contributors is the better list at this point to discuss dev-related questions/ideas. (Subscribe by sending an email to [hidden email]) -- Matthew Weier O'Phinney Project Lead | [hidden email] Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc -- List: [hidden email] Info: http://framework.zend.com/archives Unsubscribe: [hidden email] |
| Powered by Nabble | Edit this page |
