arpadboda commented on a change in pull request #560: MINIFICPP-852: Add 
details to restful response. CoAP will not include…
URL: https://github.com/apache/nifi-minifi-cpp/pull/560#discussion_r285503528
 
 

 ##########
 File path: libminifi/include/core/logging/LoggingInterceptor.h
 ##########
 @@ -0,0 +1,117 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LIBMINIFI_INCLUDE_CORE_LOGGING_LOGGINGINTERCEPTOR_H_
+#define LIBMINIFI_INCLUDE_CORE_LOGGING_LOGGINGINTERCEPTOR_H_
+
+#include <vector>
+#include <mutex>
+#include <algorithm>
+#include "core/expect.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace core {
+namespace logging {
+
+class Interceptor {
+ public:
+  void intercept_error(const std::string &msg) {
+    std::lock_guard<std::mutex> lock(guard_);
+    errors_.emplace_back(msg);
+  }
+
+  const std::vector<std::string> &getErrors() const {
+    return errors_;
 
 Review comment:
   I'm a bit afraid of this. 
   When errors are logged the intercept_error func above will lock the mutex, 
although whoever calling this function will get a reference to the vector 
without knowing about the mutex. 
   I would prefer lock and copy here.  A match function (to be able to search 
for specific errors using regex) would be nice, too - that can do the job using 
the lock and avoid copies. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to