From 12c3275c36aa72f0851ecba3a3fbe23aefc7d1ed Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Tue, 3 Sep 2019 20:14:35 -0700 Subject: [PATCH] truncate module --- ws/ws_autobahn.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ws/ws_autobahn.cpp b/ws/ws_autobahn.cpp index b1dc84a1..1c18bcf6 100644 --- a/ws/ws_autobahn.cpp +++ b/ws/ws_autobahn.cpp @@ -43,6 +43,21 @@ #include +namespace +{ + std::string truncate(const std::string& str, size_t n) + { + if (str.size() < n) + { + return str; + } + else + { + return str.substr(0, n) + "..."; + } + } +} + namespace ix { class AutobahnTestCase @@ -117,7 +132,7 @@ namespace ix ss << "Received " << msg->wireSize << " bytes" << std::endl; ss << "autobahn: received message: " - << msg->str + << truncate(msg->str, 40) << std::endl; _webSocket.send(msg->str, msg->binary);