[libcamera-devel,v3] libcamera: log: Expand log level names

Message ID 20200129121000.23135-1-kieran.bingham@ideasonboard.com
State Accepted
Commit 1a6d0f5e9a46f7bd32af1a0b2667f14e7911f93d
Headers show
Series
  • [libcamera-devel,v3] libcamera: log: Expand log level names
Related show

Commit Message

Kieran Bingham Jan. 29, 2020, 12:10 p.m. UTC
When the log severity names were added, there was only 4 characters
reserved for their printing. When the FATAL level was added, this
increased to 5, and thus both DBG and ERR can be expanded to their full
spelling. This also brings the levels in line with the representation
that can be used when calling logSetLevel().

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---

v3:
 - Rebase to master with Trhead::currentID() section.

v2:
 - Expand commit message
 - Expand spacing before the log severity name is printed.


 src/libcamera/log.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Patch

diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp
index 1c82dc68fb0f..fd1b5c39a52e 100644
--- a/src/libcamera/log.cpp
+++ b/src/libcamera/log.cpp
@@ -84,10 +84,10 @@  static int log_severity_to_syslog(LogSeverity severity)
 static const char *log_severity_name(LogSeverity severity)
 {
 	static const char *const names[] = {
-		"  DBG",
+		"DEBUG",
 		" INFO",
 		" WARN",
-		"  ERR",
+		"ERROR",
 		"FATAL",
 	};
 
@@ -198,7 +198,7 @@  void LogOutput::write(const LogMessage &msg)
 	case LoggingTargetStream:
 	case LoggingTargetFile:
 		str = "[" + utils::time_point_to_string(msg.timestamp()) + "] ["
-		    + std::to_string(Thread::currentId()) + "]"
+		    + std::to_string(Thread::currentId()) + "] "
 		    + log_severity_name(msg.severity()) + " "
 		    + msg.category().name() + " " + msg.fileInfo() + " "
 		    + msg.msg();