You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/10/20 13:45:54 UTC

[GitHub] [nifi-minifi-cpp] lordgamez opened a new pull request #1202: MINIFICPP-1667 Add Azure SDK logging to Minifi

lordgamez opened a new pull request #1202:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1202


   https://issues.apache.org/jira/browse/MINIFICPP-1667
   
   -------------------------------------------------------------------
   Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced
        in the commit message?
   
   - [ ] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically main)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   ### For code changes:
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the LICENSE file?
   - [ ] If applicable, have you updated the NOTICE file?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
   


-- 
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-unsubscribe@nifi.apache.org

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



[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1202: MINIFICPP-1667 Add Azure SDK logging to Minifi

Posted by GitBox <gi...@apache.org>.
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-unsubscribe@nifi.apache.org

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



[GitHub] [nifi-minifi-cpp] adam-markovics commented on a change in pull request #1202: MINIFICPP-1667 Add Azure SDK logging to Minifi

Posted by GitBox <gi...@apache.org>.
adam-markovics commented on a change in pull request #1202:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1202#discussion_r733492638



##########
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:
       If I understand this well, it means that log messages from Azure will be logged by MiNiFi as well. Will it be clear from MiNiFi logs, that a message came from Azure? If log messages are not prefixed in any way, it could be problematic to find out where they originally came from.

##########
File path: extensions/azure/utils/AzureSdkLogger.h
##########
@@ -0,0 +1,42 @@
+/**
+ * @file AzureSdkLogger.h
+ * AzureSdkLogger class declaration
+ *
+ * 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.
+ */
+#pragma once
+
+#include <memory>
+
+#include "azure/core/diagnostics/logger.hpp"

Review comment:
       Is this include necessary in the header? It's also present in the source.




-- 
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-unsubscribe@nifi.apache.org

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



[GitHub] [nifi-minifi-cpp] adam-markovics commented on a change in pull request #1202: MINIFICPP-1667 Add Azure SDK logging to Minifi

Posted by GitBox <gi...@apache.org>.
adam-markovics commented on a change in pull request #1202:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1202#discussion_r733504662



##########
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:
       Yes, I think it's enough, that's a prefix.




-- 
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-unsubscribe@nifi.apache.org

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



[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1202: MINIFICPP-1667 Add Azure SDK logging to Minifi

Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1202:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1202#discussion_r733503180



##########
File path: extensions/azure/utils/AzureSdkLogger.h
##########
@@ -0,0 +1,42 @@
+/**
+ * @file AzureSdkLogger.h
+ * AzureSdkLogger class declaration
+ *
+ * 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.
+ */
+#pragma once
+
+#include <memory>
+
+#include "azure/core/diagnostics/logger.hpp"

Review comment:
       That was unnecessary, removed in 51e5a10c3ff0cfbaa507b95425f939f89e8c2279




-- 
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-unsubscribe@nifi.apache.org

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



[GitHub] [nifi-minifi-cpp] fgerlits closed pull request #1202: MINIFICPP-1667 Add Azure SDK logging to Minifi

Posted by GitBox <gi...@apache.org>.
fgerlits closed pull request #1202:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1202


   


-- 
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-unsubscribe@nifi.apache.org

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