Uploaded image for project: 'Log4php'
  1. Log4php
  2. LOG4PHP-18

Date pattern %d conversion is invalid.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      log4php r692607,
      PHP 5.2.4-2ubuntu5.3 with Suhosin-Patch 0.9.6.2,
      Ubuntu 8.04

      Description

      Date pattern %d conversion includes fragile regular expression and arbitrary substitute of ','.
      So user definition pattern (%d

      {format}

      ) is not converted well.

      patch as follows.
      ---------------------------------------------------------------------------------
      diff -urN log4php/helpers/LoggerPatternConverter.php log4php.new/helpers/LoggerPatternConverter.php
      — log4php/helpers/LoggerPatternConverter.php
      +++ log4php.new/helpers/LoggerPatternConverter.php
      @@ -289,7 +289,7 @@
      {
      $timeStamp = $event->getTimeStamp();
      $usecs = round(($timeStamp - (int)$timeStamp) * 1000);

      • $this->df = str_replace("\u", "u", ereg_replace("[^
        ]u", sprintf(',%03d', $usecs), $this->df));
        + $this->df = preg_replace('/((?<!\\\\)(?:\\\\ {2}

        )*)u/', '${1}' . sprintf('%03d', $usecs), $this->df);

      return date($this->df, $event->getTimeStamp());

      ---------------------------------------------------------------------------------

        Attachments

          Activity

            People

            • Assignee:
              kurdalen Knut Urdalen
              Reporter:
              whitestar Yomei Komiya
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: