]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 4870: milliseconds logformats prepend 0s instead of spaces (#255) M-staged-PR255
authorAmos Jeffries <yadij@users.noreply.github.com>
Wed, 25 Jul 2018 13:47:20 +0000 (13:47 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Thu, 26 Jul 2018 10:47:12 +0000 (10:47 +0000)
src/format/Format.cc

index 82d13bf8b0eae2e66a4fc3f665cf11403f4f1b00..ec9b3db08fa491b44828cbb5b0cefa25dfdf4e15 100644 (file)
@@ -1389,7 +1389,7 @@ Format::Format::assemble(MemBuf &mb, const AccessLogEntry::Pointer &al, int logS
             out = sb.c_str();
         } else if (doMsec) {
             if (fmt->widthMax < 0) {
-                sb.appendf("%0*ld", fmt->widthMin, tvToMsec(outtv));
+                sb.appendf("%0*ld", fmt->zero && fmt->widthMin >= 0 ? fmt->widthMin : 0, tvToMsec(outtv));
             } else {
                 int precision = fmt->widthMax;
                 sb.appendf("%0*" PRId64 ".%0*" PRId64 "", fmt->zero && (fmt->widthMin - precision - 1 >= 0) ? fmt->widthMin - precision - 1 : 0, static_cast<int64_t>(outtv.tv_sec * 1000 + outtv.tv_usec / 1000), precision, static_cast<int64_t>((outtv.tv_usec % 1000 )* (1000 / fmt->divisor)));