lordgamez commented on a change in pull request #1202:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1202#discussion_r733502489



##########
File path: extensions/azure/utils/AzureSdkLogger.cpp
##########
@@ -0,0 +1,68 @@
+/**
+ * @file AzureSdkLogger.cpp
+ * AzureSdkLogger class implementation
+ *
+ * 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.
+ */
+
+#include "AzureSdkLogger.h"
+
+#include <string>
+
+#include "azure/core/diagnostics/logger.hpp"
+
+namespace org::apache::nifi::minifi::azure::utils {
+
+void AzureSdkLogger::initialize() {
+  static AzureSdkLogger instance;
+}
+
+void AzureSdkLogger::setLogLevel() {
+  if (logger_->should_log(minifi::core::logging::LOG_LEVEL::trace) || 
logger_->should_log(minifi::core::logging::LOG_LEVEL::debug)) {
+    
Azure::Core::Diagnostics::Logger::SetLevel(Azure::Core::Diagnostics::Logger::Level::Verbose);
+  } else if (logger_->should_log(minifi::core::logging::LOG_LEVEL::info)) {
+    
Azure::Core::Diagnostics::Logger::SetLevel(Azure::Core::Diagnostics::Logger::Level::Informational);
+  } else if (logger_->should_log(minifi::core::logging::LOG_LEVEL::warn)) {
+    
Azure::Core::Diagnostics::Logger::SetLevel(Azure::Core::Diagnostics::Logger::Level::Warning);
+  } else if (logger_->should_log(minifi::core::logging::LOG_LEVEL::err) || 
logger_->should_log(minifi::core::logging::LOG_LEVEL::critical)) {
+    
Azure::Core::Diagnostics::Logger::SetLevel(Azure::Core::Diagnostics::Logger::Level::Error);
+  }
+}
+
+AzureSdkLogger::AzureSdkLogger() {
+  setLogLevel();
+
+  
Azure::Core::Diagnostics::Logger::SetListener([&](Azure::Core::Diagnostics::Logger::Level
 level, const std::string& message) {
+    switch (level) {
+      case Azure::Core::Diagnostics::Logger::Level::Verbose:
+        logger_->log_debug(message.c_str());

Review comment:
       The distinction currently is that the logs from Azure are tagged with 
`org::apache::nifi::minifi::azure::utils::AzureSdkLogger`. Some sample logs 
look like this now:
   ```
   [2021-10-20 15:14:34.652] 
[org::apache::nifi::minifi::azure::storage::AzureBlobStorageClient] [debug] 
Azure Blob Storage client has been reset with new managed identity credentials.
   [2021-10-20 15:14:34.652] 
[org::apache::nifi::minifi::azure::utils::AzureSdkLogger] [info] HTTP Request : 
GET 
http://169.254.169.254/metadata/identity/oauth2/token?api-version=REDACTED&resource=REDACTED
   metadata : REDACTED
   user-agent : azsdk-cpp-identity/1.2.0-beta.1 (Linux 5.8.0-1042-azure x86_64 
#45~20.04.1-Ubuntu SMP Wed Sep 15 14:24:15 UTC 2021)
   x-ms-client-request-id : e6c4b503-7843-415b-4542-5e9f1ed65dea
   [2021-10-20 15:14:34.652] 
[org::apache::nifi::minifi::azure::utils::AzureSdkLogger] [debug] [CURL 
Transport Adapter]: Creating a new session.
   [2021-10-20 15:14:34.654] 
[org::apache::nifi::minifi::azure::utils::AzureSdkLogger] [debug] [CURL 
Transport Adapter]: No Host in request headers. Adding it
   [2021-10-20 15:14:34.654] 
[org::apache::nifi::minifi::azure::utils::AzureSdkLogger] [debug] [CURL 
Transport Adapter]: No content-length in headers. Adding it
   [2021-10-20 15:14:34.654] 
[org::apache::nifi::minifi::azure::utils::AzureSdkLogger] [debug] [CURL 
Transport Adapter]: Send request without payload
   [2021-10-20 15:14:34.654] 
[org::apache::nifi::minifi::azure::utils::AzureSdkLogger] [debug] [CURL 
Transport Adapter]: Parse server response
   [2021-10-20 15:14:35.561] [org::apache::nifi::minifi::processors::GetFile] 
[debug] Listing is empty before polling directory
   ```
   
   Do you think that is enough, or we would need some additional distinction 
with some additional prefix or any other means of tagging?




-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to