[libcamera-devel] [PATCH 2/8] libcamera: request: Add a toString()
Kieran Bingham
kieran.bingham at ideasonboard.com
Fri Mar 12 07:11:25 CET 2021
Provide a toString helper to assist in printing Request state
for debug and logging contexts.
Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---
include/libcamera/request.h | 2 ++
src/libcamera/request.cpp | 20 +++++++++++++++++++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/include/libcamera/request.h b/include/libcamera/request.h
index 6f2f881e840a..59d7f4bac0d2 100644
--- a/include/libcamera/request.h
+++ b/include/libcamera/request.h
@@ -56,6 +56,8 @@ public:
bool hasPendingBuffers() const { return !pending_.empty(); }
+ const std::string toString() const;
+
private:
LIBCAMERA_DISABLE_COPY(Request)
diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
index 24c3694de5fc..12c2e7d425f9 100644
--- a/src/libcamera/request.cpp
+++ b/src/libcamera/request.cpp
@@ -268,7 +268,7 @@ void Request::complete()
status_ = cancelled_ ? RequestCancelled : RequestComplete;
LOG(Request, Debug)
- << "Request has completed - cookie: " << cookie_
+ << toString() << " has completed - cookie: " << cookie_
<< (cancelled_ ? " [Cancelled]" : "");
LIBCAMERA_TRACEPOINT(request_complete, this);
@@ -302,4 +302,22 @@ bool Request::completeBuffer(FrameBuffer *buffer)
return !hasPendingBuffers();
}
+const std::string Request::toString() const
+{
+ std::stringstream ss;
+
+ static const char *statuses[] = {
+ "Pending",
+ "Complete",
+ "Cancelled",
+ };
+
+ ss << "Request (" << sequence_ << ") " << statuses[status_];
+
+ if (hasPendingBuffers())
+ ss << " [Pending:" << pending_.size() << "]";
+
+ return ss.str();
+}
+
} /* namespace libcamera */
--
2.25.1
More information about the libcamera-devel
mailing list