Quantcast

Zend_Log Dateformat

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Zend_Log Dateformat

Steve Rayner-2
Zend_Log has this in the Log() function;

        // pack into event required by filters and writers
        $event = array_merge(array('timestamp'    => date('c'),
                                    'message'      => $message,
                                    'priority'     => $priority,
                                    'priorityName' =>
$this->_priorities[$priority]),
                              $this->_extras);

Which uses ISO format for date. However Firebird database does not
seem to accept dates in this format.
How should I go about overriding the date format in Zend_Log.

Presumably I would have to create my own Log object that extends from
Zend_Log and override the whole Log() function.
This seems a bit extreme just to reformat a date.

I would prefer to keep ISO format in Log object and reformat the date
at the database abstraction layer, but it seems
ZendX_Db_Adapter_Firebird is not responcible for reformatting dates
(which imo kinda defeats purpose of database abstraction).
Any thoughts?

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Zend_Log Dateformat

Andreas Möller
> Zend_Log has this in the Log() function;
>
>        // pack into event required by filters and writers
>        $event = array_merge(array('timestamp'    => date('c'),
>                                    'message'      => $message,
>                                    'priority'     => $priority,
>                                    'priorityName' =>
> $this->_priorities[$priority]),
>                              $this->_extras);
>
> Which uses ISO format for date. However Firebird database does not
> seem to accept dates in this format.
> How should I go about overriding the date format in Zend_Log.
>
> Presumably I would have to create my own Log object that extends from
> Zend_Log and override the whole Log() function.
> This seems a bit extreme just to reformat a date.
>
> I would prefer to keep ISO format in Log object and reformat the date
> at the database abstraction layer, but it seems
> ZendX_Db_Adapter_Firebird is not responcible for reformatting dates
> (which imo kinda defeats purpose of database abstraction).
> Any thoughts?

If you take a look at

* https://github.com/svenax/ZendFramework/blob/release-1.11.11/library/Zend/Log.php#L141

you'll see that the format of the timestamp can actually be configured. I assume that this is the same in the latest 1.12.0 release.


Best regards,

Andreas
--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Zend_Log Dateformat

David Muir-2
In reply to this post by Steve Rayner-2
Swap out the formatter for the writer.

ZF1:
http://framework.zend.com/manual/1.12/en/zend.log.formatters.html

ZF2:
http://framework.zend.com/manual/2.0/en/modules/zend.log.formatters.html

Cheers,
David

On 14/09/2012, at 6:17 PM, Steve Rayner <[hidden email]> wrote:

> Zend_Log has this in the Log() function;
>
>        // pack into event required by filters and writers
>        $event = array_merge(array('timestamp'    => date('c'),
>                                    'message'      => $message,
>                                    'priority'     => $priority,
>                                    'priorityName' =>
> $this->_priorities[$priority]),
>                              $this->_extras);
>
> Which uses ISO format for date. However Firebird database does not
> seem to accept dates in this format.
> How should I go about overriding the date format in Zend_Log.
>
> Presumably I would have to create my own Log object that extends from
> Zend_Log and override the whole Log() function.
> This seems a bit extreme just to reformat a date.
>
> I would prefer to keep ISO format in Log object and reformat the date
> at the database abstraction layer, but it seems
> ZendX_Db_Adapter_Firebird is not responcible for reformatting dates
> (which imo kinda defeats purpose of database abstraction).
> Any thoughts?
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>
>

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Zend_Log Dateformat

Steve Rayner-2
In reply to this post by Andreas Möller
Easy. I just needed to upgrade from ZF1.10 to ZF1.12.
As you say you can now specify the timestamp format.

        $logger = new Zend_Log();
        $logger->setTimestampFormat('Y-m-d H:i:s');

Thanks
srayner

On Fri, Sep 14, 2012 at 10:17 AM, Andreas Möller <[hidden email]> wrote:

>> Zend_Log has this in the Log() function;
>>
>>        // pack into event required by filters and writers
>>        $event = array_merge(array('timestamp'    => date('c'),
>>                                    'message'      => $message,
>>                                    'priority'     => $priority,
>>                                    'priorityName' =>
>> $this->_priorities[$priority]),
>>                              $this->_extras);
>>
>> Which uses ISO format for date. However Firebird database does not
>> seem to accept dates in this format.
>> How should I go about overriding the date format in Zend_Log.
>>
>> Presumably I would have to create my own Log object that extends from
>> Zend_Log and override the whole Log() function.
>> This seems a bit extreme just to reformat a date.
>>
>> I would prefer to keep ISO format in Log object and reformat the date
>> at the database abstraction layer, but it seems
>> ZendX_Db_Adapter_Firebird is not responcible for reformatting dates
>> (which imo kinda defeats purpose of database abstraction).
>> Any thoughts?
>
> If you take a look at
>
> * https://github.com/svenax/ZendFramework/blob/release-1.11.11/library/Zend/Log.php#L141
>
> you'll see that the format of the timestamp can actually be configured. I assume that this is the same in the latest 1.12.0 release.
>
>
> Best regards,
>
> Andreas

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Loading...