zendframework/zf2 — pull request #2029 by jmikola (2012-07-27 17:29:30+00:00)
Title: Rely on log formatters for DateTime formatting

See: [this thread on fw-core](http://zend-framework-community.634137.n4.nabble.com/fw-core-Relocating-Logger-log-date-formatting-to-formatters-td4655676.html) for context.

This shifts date formatting responsibilities to the log formatter classes. The basic logic I used was to check whether the `timestamp` field in event data is a DateTime, and invoke it's `format()` method if so. Writers that do not support a formatter, or those that work with event data outside of `FormatterInterface::format()`, will be responsible for handling the DateTime object on their own.

Here is the state of the existing writers:

* **Db**: This writer doesn't support a formatter. I assume the `timestamp` field in event data is currently inserted into a string column. Ideally, I think we'd want to store this as a native date type, but I'm not familiar enough with the DB layer to determine how to accomplish this.
* **FirePhp**: This only references the `message` and `priority` fields in event data. In its formatter class, I implemented the `setDateTimeFormat()` method (to adhere to the interface change) but it does nothing.
* **Mail** and **Stream**: These writers construct a vanilla SimpleFormatter internally, which means the default date format (ISO 8601) will be used unless the user changes the formatter with the writer's `setFormatter()` method. I suppose this is OK.
* **MongoDB**: If the `timestamp` field in event data is a DateTime instance, it is converted to MongoDate.
* **Syslog**: Formatters are optional. Without a formatter, only the `message` field in event data is used. I don't think anything needs to be done here.
* **ZendMonitor**: I also unfamiliar with this writer and I found little documentation on the `zend_monitor_custom_event()` and `monitor_custom_event()` functions. Would this writer require conversion of the DateTime object, or is it reasonable to store that directly?