libcamera: log: Pad timestamp fields with zeros

The logger prints the timestamp fields with a fixed width, but pads them
with spaces instead of zeros. Fix this.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
Laurent Pinchart 2019-01-05 14:08:46 +02:00
parent ce24c052de
commit f3829b5745

View file

@ -101,10 +101,12 @@ LogMessage::LogMessage(const char *fileName, unsigned int line,
/* Log the timestamp, severity and file information. */
struct timespec timestamp;
clock_gettime(CLOCK_MONOTONIC, &timestamp);
msgStream.fill('0');
msgStream << "[" << timestamp.tv_sec / (60 * 60) << ":"
<< std::setw(2) << (timestamp.tv_sec / 60) % 60 << ":"
<< std::setw(2) << timestamp.tv_sec % 60 << "."
<< std::setw(9) << timestamp.tv_nsec << "]";
msgStream.fill(' ');
msgStream << " " << log_severity_name(severity);
msgStream << " " << basename(fileName) << ":" << line << " ";