[libcamera-devel,v2,03/11] libcamera: log: Pad timestamp fields with zeros

Message ID 20190107231151.23291-4-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • libcamera: Add event notification and timers
Related show

Commit Message

Laurent Pinchart Jan. 7, 2019, 11:11 p.m. UTC
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>
---
 src/libcamera/log.cpp | 2 ++
 1 file changed, 2 insertions(+)

Patch

diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp
index 6785d371449e..c1ec55618ea3 100644
--- a/src/libcamera/log.cpp
+++ b/src/libcamera/log.cpp
@@ -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 << " ";