You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-user@logging.apache.org by Clay Loveless <cl...@killersoft.com> on 2006/01/16 20:08:05 UTC
Configurable msec separator
Hello,
I would like to see a patch like this applied to the Log4php package, in
helpers/LoggerPatternConverter.php:
--- LoggerPatternConverter.php 2003-12-09 14:50:14.000000000 -0800
+++ LoggerPatternConverter.php 2006-01-16 11:00:09.000000000 -0800
@@ -286,7 +286,8 @@
{
$timeStamp = $event->getTimeStamp();
$usecs = round(($timeStamp - (int)$timeStamp) * 1000);
- $this->df = str_replace("\u", "u", ereg_replace("[^\\]u",
sprintf(',%03d', $usecs), $this->df));
+ $msecsep = defined('LOG4PHP_LOGGER_PATTERN_MSEC_SEPARATOR') ?
LOG4PHP_LOGGER_PATTERN_MSEC_SEPARATOR : ',';
+ $this->df = str_replace("\u", "u", preg_replace("/[^\\\]u/",
sprintf("{$msecsep}%03d", $usecs), $this->df));
return date($this->df, $event->getTimeStamp());
... Basically, I'd like to be able to easily define what the msec separator
is when I request msecs in my log configuration.
The patch above allows for that level of configuration, without breaking
backwards compatibility for those who expect a comma to be the separator.
The patch also replaces ereg_replace() function with the faster
preg_replace() version.
What do you guys think?
Regards,
Clay
--
Killersoft.com
Re: Configurable msec separator
Posted by Clay Loveless <cl...@killersoft.com>.
Hi Marco,
That sounds like a fine solution to me -- the end result is the same, which
is all I'm after. :)
Regards,
Clay
--
Killersoft.com
> From: "Marco V." <ma...@apache.org>
> Reply-To: Log4PHP User <lo...@logging.apache.org>
> Date: Wed, 25 Jan 2006 14:38:16 +0100
> To: Log4PHP User <lo...@logging.apache.org>
> Subject: Re: Configurable msec separator
>
> Hi Clay,
>
> The LOG4PHP_LOGGER_PATTERN_MSEC_SEPARATOR can be useful.
> IHMO, it's better to define it before
> $GLOBALS['log4php.LoggerPatternConverter.spaces'] declaration.
>
> with something like this:
>
> /**
> * Phpdoc comments here...
> */
> if (!defined('LOG4PHP_LOGGER_PATTERN_MSEC_SEPARATOR')) {
> define('LOG4PHP_LOGGER_PATTERN_MSEC_SEPARATOR', ',');
> }
>
> and use it without $msecsep.
> What do you think about this approach ?
>
> -Marco
>
> ----- Original Message -----
> From: "Clay Loveless" <cl...@killersoft.com>
> To: <lo...@logging.apache.org>
> Sent: Monday, January 16, 2006 8:08 PM
> Subject: Configurable msec separator
>
>
>> Hello,
>>
>> I would like to see a patch like this applied to the Log4php package, in
>> helpers/LoggerPatternConverter.php:
>>
>> --- LoggerPatternConverter.php 2003-12-09 14:50:14.000000000 -0800
>> +++ LoggerPatternConverter.php 2006-01-16 11:00:09.000000000 -0800
>> @@ -286,7 +286,8 @@
>> {
>> $timeStamp = $event->getTimeStamp();
>> $usecs = round(($timeStamp - (int)$timeStamp) * 1000);
>> - $this->df = str_replace("\u", "u", ereg_replace("[^\\]u",
>> sprintf(',%03d', $usecs), $this->df));
>> + $msecsep = defined('LOG4PHP_LOGGER_PATTERN_MSEC_SEPARATOR') ?
>> LOG4PHP_LOGGER_PATTERN_MSEC_SEPARATOR : ',';
>> + $this->df = str_replace("\u", "u", preg_replace("/[^\\\]u/",
>> sprintf("{$msecsep}%03d", $usecs), $this->df));
>>
>> return date($this->df, $event->getTimeStamp());
>>
>>
>> ... Basically, I'd like to be able to easily define what the msec separator
>> is when I request msecs in my log configuration.
>>
>> The patch above allows for that level of configuration, without breaking
>> backwards compatibility for those who expect a comma to be the separator.
>>
>> The patch also replaces ereg_replace() function with the faster
>> preg_replace() version.
>>
>>
>> What do you guys think?
>>
>> Regards,
>> Clay
>>
>> --
>> Killersoft.com
>>
>>
>>
>>
Re: Configurable msec separator
Posted by "Marco V." <ma...@apache.org>.
Hi Clay,
The LOG4PHP_LOGGER_PATTERN_MSEC_SEPARATOR can be useful.
IHMO, it's better to define it before $GLOBALS['log4php.LoggerPatternConverter.spaces'] declaration.
with something like this:
/**
* Phpdoc comments here...
*/
if (!defined('LOG4PHP_LOGGER_PATTERN_MSEC_SEPARATOR')) {
define('LOG4PHP_LOGGER_PATTERN_MSEC_SEPARATOR', ',');
}
and use it without $msecsep.
What do you think about this approach ?
-Marco
----- Original Message -----
From: "Clay Loveless" <cl...@killersoft.com>
To: <lo...@logging.apache.org>
Sent: Monday, January 16, 2006 8:08 PM
Subject: Configurable msec separator
> Hello,
>
> I would like to see a patch like this applied to the Log4php package, in
> helpers/LoggerPatternConverter.php:
>
> --- LoggerPatternConverter.php 2003-12-09 14:50:14.000000000 -0800
> +++ LoggerPatternConverter.php 2006-01-16 11:00:09.000000000 -0800
> @@ -286,7 +286,8 @@
> {
> $timeStamp = $event->getTimeStamp();
> $usecs = round(($timeStamp - (int)$timeStamp) * 1000);
> - $this->df = str_replace("\u", "u", ereg_replace("[^\\]u",
> sprintf(',%03d', $usecs), $this->df));
> + $msecsep = defined('LOG4PHP_LOGGER_PATTERN_MSEC_SEPARATOR') ?
> LOG4PHP_LOGGER_PATTERN_MSEC_SEPARATOR : ',';
> + $this->df = str_replace("\u", "u", preg_replace("/[^\\\]u/",
> sprintf("{$msecsep}%03d", $usecs), $this->df));
>
> return date($this->df, $event->getTimeStamp());
>
>
> ... Basically, I'd like to be able to easily define what the msec separator
> is when I request msecs in my log configuration.
>
> The patch above allows for that level of configuration, without breaking
> backwards compatibility for those who expect a comma to be the separator.
>
> The patch also replaces ereg_replace() function with the faster
> preg_replace() version.
>
>
> What do you guys think?
>
> Regards,
> Clay
>
> --
> Killersoft.com
>
>
>
>