This is an automated email from the ASF dual-hosted git repository.

bennoe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 44adcf93f79c9b3ce85ffe2c1fb5792a48fbd543
Author: Benno Evers <[email protected]>
AuthorDate: Fri Mar 22 17:35:27 2019 +0100

    Added stream operator overload for OperationStatus messages.
    
    This commit adds a new overload
    
        ostream& operator<<(ostream&, const OperationStatus&);
    
    to make the printing of OperationStatus messages
    more convenient.
    
    Review: https://reviews.apache.org/r/70281
---
 include/mesos/v1/mesos.hpp |  3 +++
 src/v1/mesos.cpp           | 30 ++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/include/mesos/v1/mesos.hpp b/include/mesos/v1/mesos.hpp
index dc328bf..df67f64 100644
--- a/include/mesos/v1/mesos.hpp
+++ b/include/mesos/v1/mesos.hpp
@@ -412,6 +412,9 @@ std::ostream& operator<<(
 std::ostream& operator<<(std::ostream& stream, const TaskStatus& status);
 
 
+std::ostream& operator<<(std::ostream& stream, const OperationStatus& status);
+
+
 std::ostream& operator<<(std::ostream& stream, const AgentID& agentId);
 
 
diff --git a/src/v1/mesos.cpp b/src/v1/mesos.cpp
index 704ad76..be479e3 100644
--- a/src/v1/mesos.cpp
+++ b/src/v1/mesos.cpp
@@ -667,6 +667,36 @@ ostream& operator<<(ostream& stream, const TaskStatus& 
status)
 }
 
 
+ostream& operator<<(ostream& stream, const OperationStatus& status)
+{
+  stream << status.state();
+
+  if (status.has_uuid()) {
+    stream << " (Status UUID: "
+           << stringify(id::UUID::fromBytes(status.uuid().value()).get())
+           << ")";
+  }
+
+  if (status.has_message()) {
+    stream << " Message: '" << status.message() << "'";
+  }
+
+  if (status.has_operation_id()) {
+    stream << " for operation '" << status.operation_id() << "'";
+  }
+
+  if (status.has_agent_id()) {
+    stream << " on agent: " << status.agent_id() << "";
+  }
+
+  if (status.has_resource_provider_id()) {
+    stream << " on resource provider: " << status.resource_provider_id() << "";
+  }
+
+  return stream;
+}
+
+
 ostream& operator<<(ostream& stream, const AgentID& agentId)
 {
   return stream << agentId.value();

Reply via email to