Improve log messages and general code cleanup in CaModule

Change-Id: Ie455ec14594e7662800faa887da72574bff73407
diff --git a/src/detail/error-encoder.cpp b/src/detail/error-encoder.cpp
index db2b1ca..546ca4f 100644
--- a/src/detail/error-encoder.cpp
+++ b/src/detail/error-encoder.cpp
@@ -27,10 +27,10 @@
 NDN_LOG_INIT(ndncert.encode.error);
 
 Block
-encodeDataContent(ErrorCode errorCode, const std::string& description)
+encodeDataContent(ErrorCode errorCode, std::string_view description)
 {
   Block response(ndn::tlv::Content);
-  response.push_back(ndn::makeNonNegativeIntegerBlock(tlv::ErrorCode, static_cast<size_t>(errorCode)));
+  response.push_back(ndn::makeNonNegativeIntegerBlock(tlv::ErrorCode, static_cast<uint64_t>(errorCode)));
   response.push_back(ndn::makeStringBlock(tlv::ErrorInfo, description));
   response.encode();
   return response;
@@ -68,8 +68,9 @@
       return {ErrorCode::NO_ERROR, ""};
     }
     if (codeCount != 1 || infoCount != 1) {
-      NDN_THROW(std::runtime_error("Error TLV contains " + std::to_string(codeCount) + " error code(s) and " +
-                                   std::to_string(infoCount) + " error info(s), instead of expected 1 time each."));
+      NDN_THROW(std::runtime_error("Error TLV contains " + std::to_string(codeCount) +
+                                   " error code(s) and " + std::to_string(infoCount) +
+                                   " error info(s), instead of expected 1 time each."));
     }
     if (otherCriticalCount > 0) {
       NDN_THROW(std::runtime_error("Unknown critical TLV type in error packet"));
diff --git a/src/detail/error-encoder.hpp b/src/detail/error-encoder.hpp
index d41e6f6..53581f4 100644
--- a/src/detail/error-encoder.hpp
+++ b/src/detail/error-encoder.hpp
@@ -31,7 +31,7 @@
  * Encode error information into a Data content TLV
  */
 Block
-encodeDataContent(ErrorCode errorCode, const std::string& description);
+encodeDataContent(ErrorCode errorCode, std::string_view description);
 
 /**
  * Decode error information from Data content TLV
diff --git a/src/detail/info-encoder.cpp b/src/detail/info-encoder.cpp
index 4c260b4..2d327ba 100644
--- a/src/detail/info-encoder.cpp
+++ b/src/detail/info-encoder.cpp
@@ -20,12 +20,8 @@
 
 #include "detail/info-encoder.hpp"
 
-#include <ndn-cxx/util/logger.hpp>
-
 namespace ndncert::infotlv {
 
-NDN_LOG_INIT(ndncert.encode.info);
-
 Block
 encodeDataContent(const CaProfile& caConfig, const Certificate& certificate)
 {
@@ -45,7 +41,6 @@
   content.push_back(ndn::makeNonNegativeIntegerBlock(tlv::MaxValidityPeriod, caConfig.maxValidityPeriod.count()));
   content.push_back(makeNestedBlock(tlv::CaCertificate, certificate));
   content.encode();
-  NDN_LOG_TRACE("Encoding INFO packet with certificate " << certificate.getFullName());
   return content;
 }
 
diff --git a/src/detail/request-encoder.cpp b/src/detail/request-encoder.cpp
index 1187243..d240209 100644
--- a/src/detail/request-encoder.cpp
+++ b/src/detail/request-encoder.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2022, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -60,7 +60,7 @@
       ecdhPubCount++;
     }
     else if ((requestType == RequestType::NEW && item.type() == tlv::CertRequest) ||
-               (requestType == RequestType::REVOKE && item.type() == tlv::CertToRevoke)) {
+             (requestType == RequestType::REVOKE && item.type() == tlv::CertToRevoke)) {
       requestPayload = item;
       requestPayloadCount++;
       requestPayload.parse();
@@ -75,9 +75,9 @@
   }
 
   if (ecdhPubCount != 1 || requestPayloadCount != 1) {
-    NDN_THROW(std::runtime_error("Error TLV contains " + std::to_string(ecdhPubCount) + " ecdh public param(s) and " +
-                                 std::to_string(requestPayloadCount) +
-                                 "request payload(s), instead of expected 1 times each."));
+    NDN_THROW(std::runtime_error("TLV contains " + std::to_string(ecdhPubCount) +
+                                 " ecdh public param(s) and " + std::to_string(requestPayloadCount) +
+                                 " request payload(s), instead of expected 1 time each"));
   }
 }
 
@@ -100,9 +100,11 @@
 
 std::list <std::string>
 requesttlv::decodeDataContent(const Block& content, std::vector <uint8_t>& ecdhKey,
-                              std::array<uint8_t, 32>& salt, RequestId& requestId) {
-  std::list<std::string> challenges;
+                              std::array<uint8_t, 32>& salt, RequestId& requestId)
+{
   content.parse();
+
+  std::list<std::string> challenges;
   int ecdhPubCount = 0, saltCount = 0, requestIdCount = 0;
   for (auto const &element : content.elements()) {
     if (element.type() == tlv::Challenge) {
@@ -128,11 +130,13 @@
       //ignore
     }
   }
+
   if (ecdhPubCount != 1 || saltCount != 1 || requestIdCount != 1) {
-    NDN_THROW(std::runtime_error("Error TLV contains " + std::to_string(ecdhPubCount) + " ecdh public param(s), " +
+    NDN_THROW(std::runtime_error("TLV contains " + std::to_string(ecdhPubCount) + " ecdh public param(s), " +
                                  std::to_string(saltCount) + " salt(s) and " + std::to_string(requestIdCount) +
-                                 "request id(s), instead of expected 1 times each."));
+                                 " request id(s), instead of expected 1 time each"));
   }
+
   return challenges;
 }