ZF-2618: Timestamp format an timezone through Zend_Date

Description

At the moment the format and the timezone of the timestamp in the log is hardcoded (date('c')).

This is very unattractive because of at least two reasons: 1. It is not possible to change the format e.g. to see milliseconds for performance profiling in the log 2. It is not possible to have a log with UTC timestamps even if the web application has other locale settings.

My recommendation is to give the possibility to assign a Zend_Date object to a Zend_Log object (or even better to a Zend_Date_Formatter object) which defines format and timezone for the log.

Comments

There is no Zend_Date_Formatter class... you can simply set your wished format with toString($format); or a convinient method if any of the standard formats is used.

Details on implementation when having problems can be asked in the I18N mailing list.

How would this be implemented? By passing an instance of Zend_Date in the constructor of Zend_Log? By passing an instance of Zend_Date on every invocation of log()? Is there any need for the flexibility to log with different date formats using the same Zend_Log object as provided by the second proposal?

I'm waiting for a response from the reporter. Thomas, do you think this is a worthy change? I'm postponing for now since this won't be fixed in the next few weeks unless a community member steps up.

Sorry for my late response... I was somehow disconnected from the watch list.

There are several ways: We could add a 'dateformat' option where you could define "yyMMDD" for example to get that format as date within your logs.

I don't know Zend_Log details but only when Zend_Log allows to use a self defined time/date we could add the possibility to attach a Zend_Date object as date/time to use. Otherwise we would overwrite the actual date as the user could with Zend_Date give a completly other date than wished.

Still there are two things to mention: First: Components should be loosly coupled... so the default behaviour should still be to use date('c') and only when configured/given within the options to use Zend_Date

Second: I think this idea should be written in a own proposal as there are several other advantages/disadvantages which have to be thought of.