From 0f524d4361fbd7b3853f88e2354a671171156347 Mon Sep 17 00:00:00 2001 From: Gabor Gyimesi Date: Tue, 21 Jan 2025 15:50:40 +0100 Subject: [PATCH] MINIFICPP-2512 Only use a single logger per processor --- extension-utils/include/core/AbstractProcessor.h | 6 +++++- extensions/bustache/ApplyTemplate.h | 7 +++---- extensions/civetweb/processors/ListenHTTP.h | 4 ++-- extensions/couchbase/processors/GetCouchbaseKey.h | 1 - extensions/couchbase/processors/PutCouchbaseKey.h | 1 - extensions/elasticsearch/PostElasticsearch.h | 4 ++-- extensions/execute-process/ExecuteProcess.h | 2 +- .../kubernetes/processors/CollectKubernetesPodMetrics.h | 2 +- extensions/libarchive/BinFiles.h | 1 - extensions/libarchive/CompressContent.h | 6 +++--- extensions/libarchive/FocusArchiveEntry.h | 6 +++--- extensions/libarchive/ManipulateArchive.h | 4 ++-- extensions/libarchive/MergeContent.h | 2 +- extensions/libarchive/UnfocusArchiveEntry.h | 6 ++---- extensions/mqtt/processors/AbstractMQTTProcessor.h | 2 -- extensions/mqtt/processors/ConsumeMQTT.h | 2 +- extensions/mqtt/processors/PublishMQTT.h | 4 ++-- extensions/opencv/CaptureRTSPFrame.h | 4 ++-- extensions/opencv/MotionDetector.h | 2 +- extensions/procfs/processors/ProcFsMonitor.h | 2 +- extensions/python/ExecutePythonProcessor.h | 3 +-- extensions/script/ExecuteScript.h | 5 ++--- extensions/smb/FetchSmb.h | 2 +- extensions/smb/ListSmb.h | 4 ++-- extensions/smb/PutSmb.h | 4 ++-- extensions/splunk/PutSplunkHTTP.h | 2 +- extensions/standard-processors/modbus/FetchModbusTcp.h | 2 +- .../standard-processors/processors/AppendHostInfo.h | 4 ++-- .../processors/AttributeRollingWindow.h | 1 - .../standard-processors/processors/AttributesToJSON.h | 4 ++-- .../standard-processors/processors/DefragmentText.h | 4 ++-- extensions/standard-processors/processors/ExtractText.h | 6 ++---- extensions/standard-processors/processors/FetchFile.h | 4 ++-- .../standard-processors/processors/GenerateFlowFile.h | 3 +-- extensions/standard-processors/processors/GetFile.h | 4 ++-- extensions/standard-processors/processors/GetTCP.h | 6 +++--- extensions/standard-processors/processors/HashContent.h | 4 ++-- extensions/standard-processors/processors/InvokeHTTP.h | 8 ++------ .../standard-processors/processors/JoltTransformJSON.h | 7 ++++--- extensions/standard-processors/processors/ListFile.h | 6 +++--- extensions/standard-processors/processors/LogAttribute.h | 2 +- extensions/standard-processors/processors/PutFile.h | 4 ++-- extensions/standard-processors/processors/PutTCP.cpp | 6 ++++-- extensions/standard-processors/processors/PutTCP.h | 3 +-- extensions/standard-processors/processors/RetryFlowFile.h | 8 ++++---- .../standard-processors/processors/RouteOnAttribute.h | 4 ++-- .../standard-processors/processors/SegmentContent.h | 7 +++---- extensions/standard-processors/processors/SplitContent.h | 5 +++-- extensions/standard-processors/processors/SplitRecord.h | 2 -- extensions/standard-processors/processors/SplitText.h | 4 ++-- extensions/standard-processors/processors/TailFile.h | 4 ++-- .../standard-processors/processors/UpdateAttribute.h | 4 ++-- .../standard-processors/tests/unit/ProcessorTests.cpp | 2 ++ extensions/systemd/ConsumeJournald.cpp | 6 ++++-- extensions/systemd/ConsumeJournald.h | 3 +-- extensions/test-processors/KamikazeProcessor.h | 4 ++-- extensions/test-processors/LogOnDestructionProcessor.h | 8 +++----- extensions/windows-event-log/ConsumeWindowsEventLog.cpp | 6 +++--- extensions/windows-event-log/ConsumeWindowsEventLog.h | 1 - .../test/libtest/unit/ReadFromFlowFileTestProcessor.h | 4 ++-- .../test/libtest/unit/WriteToFlowFileTestProcessor.h | 4 ++-- 61 files changed, 114 insertions(+), 128 deletions(-) diff --git a/extension-utils/include/core/AbstractProcessor.h b/extension-utils/include/core/AbstractProcessor.h index 113361f033..480267e19c 100644 --- a/extension-utils/include/core/AbstractProcessor.h +++ b/extension-utils/include/core/AbstractProcessor.h @@ -25,12 +25,16 @@ #include "core/Processor.h" #include "core/PropertyDefinition.h" #include "minifi-cpp/core/RelationshipDefinition.h" +#include "core/logging/LoggerFactory.h" namespace org::apache::nifi::minifi::core { template class AbstractProcessor : public ProcessorImpl { public: - using ProcessorImpl::ProcessorImpl; + explicit AbstractProcessor(std::string_view name, const utils::Identifier& uuid = {}) + : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); + } void initialize() final { static_assert(std::is_same_v); diff --git a/extensions/bustache/ApplyTemplate.h b/extensions/bustache/ApplyTemplate.h index e06e0259f4..f1390856a3 100644 --- a/extensions/bustache/ApplyTemplate.h +++ b/extensions/bustache/ApplyTemplate.h @@ -35,7 +35,9 @@ namespace org::apache::nifi::minifi::processors { class ApplyTemplate final : public core::ProcessorImpl { public: explicit ApplyTemplate(const std::string_view name, const utils::Identifier& uuid = {}) - : ProcessorImpl(name, uuid) {} + : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); + } EXTENSIONAPI static constexpr const char* Description = "Applies the mustache template specified by the \"Template\" property and writes the output to the flow file content. " "FlowFile attributes are used as template parameters."; @@ -57,9 +59,6 @@ class ApplyTemplate final : public core::ProcessorImpl { void onTrigger(core::ProcessContext& context, core::ProcessSession& session) override; void initialize() override; - - private: - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/civetweb/processors/ListenHTTP.h b/extensions/civetweb/processors/ListenHTTP.h index 4a0763df7c..d25436026b 100644 --- a/extensions/civetweb/processors/ListenHTTP.h +++ b/extensions/civetweb/processors/ListenHTTP.h @@ -55,8 +55,9 @@ class ListenHTTP : public core::ProcessorImpl { public: friend struct ::org::apache::nifi::minifi::test::ListenHTTPTestAccessor; - explicit ListenHTTP(std::string_view name, const utils::Identifier& uuid = {}) + explicit ListenHTTP(const std::string_view name, const utils::Identifier& uuid = {}) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); callbacks_.log_message = &logMessage; callbacks_.log_access = &logAccess; } @@ -284,7 +285,6 @@ class ListenHTTP : public core::ProcessorImpl { return handler_ ? handler_->requestCount() : 0; } - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); CivetCallbacks callbacks_; std::unique_ptr server_; std::unique_ptr handler_; diff --git a/extensions/couchbase/processors/GetCouchbaseKey.h b/extensions/couchbase/processors/GetCouchbaseKey.h index bec91841cd..8a74f1ccb3 100644 --- a/extensions/couchbase/processors/GetCouchbaseKey.h +++ b/extensions/couchbase/processors/GetCouchbaseKey.h @@ -107,7 +107,6 @@ class GetCouchbaseKey final : public core::AbstractProcessor { private: std::shared_ptr couchbase_cluster_service_; CouchbaseValueType document_type_ = CouchbaseValueType::Json; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::couchbase::processors diff --git a/extensions/couchbase/processors/PutCouchbaseKey.h b/extensions/couchbase/processors/PutCouchbaseKey.h index a1e3601af3..1d4429ecd4 100644 --- a/extensions/couchbase/processors/PutCouchbaseKey.h +++ b/extensions/couchbase/processors/PutCouchbaseKey.h @@ -155,7 +155,6 @@ class PutCouchbaseKey final : public core::AbstractProcessor { CouchbaseValueType document_type_ = CouchbaseValueType::Json; ::couchbase::persist_to persist_to_ = ::couchbase::persist_to::none; ::couchbase::replicate_to replicate_to_ = ::couchbase::replicate_to::none; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::couchbase::processors diff --git a/extensions/elasticsearch/PostElasticsearch.h b/extensions/elasticsearch/PostElasticsearch.h index 5274bf25ec..ff2c69a9d7 100644 --- a/extensions/elasticsearch/PostElasticsearch.h +++ b/extensions/elasticsearch/PostElasticsearch.h @@ -38,8 +38,9 @@ class PostElasticsearch : public core::ProcessorImpl { public: EXTENSIONAPI static constexpr const char* Description = "An Elasticsearch/Opensearch post processor that uses the Elasticsearch/Opensearch _bulk REST API."; - explicit PostElasticsearch(const std::string& name, const utils::Identifier& uuid = {}) + explicit PostElasticsearch(const std::string_view name, const utils::Identifier& uuid = {}) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } ~PostElasticsearch() override = default; @@ -115,7 +116,6 @@ class PostElasticsearch : public core::ProcessorImpl { std::string host_url_; std::shared_ptr credentials_service_; http::HTTPClient client_; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::extensions::elasticsearch diff --git a/extensions/execute-process/ExecuteProcess.h b/extensions/execute-process/ExecuteProcess.h index 1992599691..d02a3587de 100644 --- a/extensions/execute-process/ExecuteProcess.h +++ b/extensions/execute-process/ExecuteProcess.h @@ -51,6 +51,7 @@ class ExecuteProcess final : public core::ProcessorImpl { explicit ExecuteProcess(const std::string_view name, const utils::Identifier& uuid = {}) : ProcessorImpl(name, uuid), working_dir_(".") { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } ~ExecuteProcess() override { if (pid_ > 0) { @@ -113,7 +114,6 @@ class ExecuteProcess final : public core::ProcessorImpl { void readOutput(core::ProcessSession& session) const; bool writeToFlowFile(core::ProcessSession& session, std::shared_ptr& flow_file, std::span buffer) const; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); std::string command_; std::string command_argument_; std::filesystem::path working_dir_; diff --git a/extensions/kubernetes/processors/CollectKubernetesPodMetrics.h b/extensions/kubernetes/processors/CollectKubernetesPodMetrics.h index 64ea727239..31a70cc0de 100644 --- a/extensions/kubernetes/processors/CollectKubernetesPodMetrics.h +++ b/extensions/kubernetes/processors/CollectKubernetesPodMetrics.h @@ -31,6 +31,7 @@ class CollectKubernetesPodMetrics : public core::ProcessorImpl { public: explicit CollectKubernetesPodMetrics(const std::string_view name, const utils::Identifier& uuid = {}) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "A processor which collects pod metrics when MiNiFi is run inside Kubernetes."; @@ -55,7 +56,6 @@ class CollectKubernetesPodMetrics : public core::ProcessorImpl { void onTrigger(core::ProcessContext& context, core::ProcessSession& session) override; private: - gsl::not_null> logger_ = gsl::make_not_null(core::logging::LoggerFactory::getLogger(uuid_)); std::shared_ptr kubernetes_controller_service_; }; diff --git a/extensions/libarchive/BinFiles.h b/extensions/libarchive/BinFiles.h index e90b708c09..9ddb056cf6 100644 --- a/extensions/libarchive/BinFiles.h +++ b/extensions/libarchive/BinFiles.h @@ -286,7 +286,6 @@ class BinFiles : public core::ProcessorImpl { BinManager binManager_; private: - std::shared_ptr logger_{core::logging::LoggerFactory::getLogger(uuid_)}; uint32_t batchSize_{1}; uint32_t maxBinCount_{100}; core::FlowFileStore file_store_; diff --git a/extensions/libarchive/CompressContent.h b/extensions/libarchive/CompressContent.h index ec136918c5..505fb8efb3 100644 --- a/extensions/libarchive/CompressContent.h +++ b/extensions/libarchive/CompressContent.h @@ -85,8 +85,9 @@ namespace org::apache::nifi::minifi::processors { class CompressContent : public core::ProcessorImpl { public: - explicit CompressContent(std::string_view name, const utils::Identifier& uuid = {}) - : core::ProcessorImpl(name, uuid) { + explicit CompressContent(const std::string_view name, const utils::Identifier& uuid = {}) + : core::ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } ~CompressContent() override = default; @@ -214,7 +215,6 @@ class CompressContent : public core::ProcessorImpl { void processFlowFile(const std::shared_ptr& flowFile, core::ProcessSession& session); - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); int compressLevel_{}; compress_content::CompressionMode compressMode_; compress_content::ExtendedCompressionFormat compressFormat_; diff --git a/extensions/libarchive/FocusArchiveEntry.h b/extensions/libarchive/FocusArchiveEntry.h index 551802a320..89be2362c6 100644 --- a/extensions/libarchive/FocusArchiveEntry.h +++ b/extensions/libarchive/FocusArchiveEntry.h @@ -38,8 +38,9 @@ namespace org::apache::nifi::minifi::processors { class FocusArchiveEntry : public core::ProcessorImpl { public: - explicit FocusArchiveEntry(std::string_view name, const utils::Identifier& uuid = {}) - : core::ProcessorImpl(name, uuid) { + explicit FocusArchiveEntry(const std::string_view name, const utils::Identifier& uuid = {}) + : core::ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } ~FocusArchiveEntry() override = default; @@ -80,7 +81,6 @@ class FocusArchiveEntry : public core::ProcessorImpl { }; private: - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); static std::shared_ptr id_generator_; }; diff --git a/extensions/libarchive/ManipulateArchive.h b/extensions/libarchive/ManipulateArchive.h index 712965b3da..769f6399f9 100644 --- a/extensions/libarchive/ManipulateArchive.h +++ b/extensions/libarchive/ManipulateArchive.h @@ -38,8 +38,9 @@ using core::logging::Logger; class ManipulateArchive : public core::ProcessorImpl { public: - explicit ManipulateArchive(std::string_view name, const utils::Identifier& uuid = {}) + explicit ManipulateArchive(const std::string_view name, const utils::Identifier& uuid = {}) : core::ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } ~ManipulateArchive() override = default; @@ -91,7 +92,6 @@ class ManipulateArchive : public core::ProcessorImpl { void initialize() override; private: - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); std::string before_, after_, operation_, destination_, targetEntry_; }; diff --git a/extensions/libarchive/MergeContent.h b/extensions/libarchive/MergeContent.h index cf88b7e1ae..e8988bb146 100644 --- a/extensions/libarchive/MergeContent.h +++ b/extensions/libarchive/MergeContent.h @@ -296,6 +296,7 @@ class MergeContent : public processors::BinFiles { public: explicit MergeContent(const std::string& name, const utils::Identifier& uuid = {}) : processors::BinFiles(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); mergeStrategy_ = merge_content_options::MERGE_STRATEGY_DEFRAGMENT; mergeFormat_ = merge_content_options::MERGE_FORMAT_CONCAT_VALUE; delimiterStrategy_ = merge_content_options::DELIMITER_STRATEGY_FILENAME; @@ -389,7 +390,6 @@ class MergeContent : public processors::BinFiles { private: void validatePropertyOptions(); - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); std::string mergeStrategy_; std::string mergeFormat_; std::string correlationAttributeName_; diff --git a/extensions/libarchive/UnfocusArchiveEntry.h b/extensions/libarchive/UnfocusArchiveEntry.h index db6cd738a6..fa662b6fba 100644 --- a/extensions/libarchive/UnfocusArchiveEntry.h +++ b/extensions/libarchive/UnfocusArchiveEntry.h @@ -40,8 +40,9 @@ using core::logging::Logger; class UnfocusArchiveEntry : public core::ProcessorImpl { public: - explicit UnfocusArchiveEntry(std::string_view name, const utils::Identifier& uuid = {}) + explicit UnfocusArchiveEntry(const std::string_view name, const utils::Identifier& uuid = {}) : core::ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } ~UnfocusArchiveEntry() override = default; @@ -74,9 +75,6 @@ class UnfocusArchiveEntry : public core::ProcessorImpl { static int ok_cb(struct archive *, void* /*d*/) { return ARCHIVE_OK; } static la_ssize_t write_cb(struct archive *, void *d, const void *buffer, size_t length); }; - - private: - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/mqtt/processors/AbstractMQTTProcessor.h b/extensions/mqtt/processors/AbstractMQTTProcessor.h index 7556826c3c..3971547f4e 100644 --- a/extensions/mqtt/processors/AbstractMQTTProcessor.h +++ b/extensions/mqtt/processors/AbstractMQTTProcessor.h @@ -323,8 +323,6 @@ class AbstractMQTTProcessor : public core::ProcessorImpl { mqtt::MqttQoS last_will_qos_{mqtt::MqttQoS::LEVEL_0}; bool last_will_retain_ = false; std::string last_will_content_type_; - - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/mqtt/processors/ConsumeMQTT.h b/extensions/mqtt/processors/ConsumeMQTT.h index e7cb23c5c0..92d10b3a80 100644 --- a/extensions/mqtt/processors/ConsumeMQTT.h +++ b/extensions/mqtt/processors/ConsumeMQTT.h @@ -41,6 +41,7 @@ class ConsumeMQTT : public processors::AbstractMQTTProcessor { public: explicit ConsumeMQTT(std::string_view name, const utils::Identifier& uuid = {}) : processors::AbstractMQTTProcessor(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "This Processor gets the contents of a FlowFile from a MQTT broker for a specified topic. " @@ -207,7 +208,6 @@ class ConsumeMQTT : public processors::AbstractMQTTProcessor { std::unordered_map alias_to_topic_; moodycamel::ConcurrentQueue queue_; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/mqtt/processors/PublishMQTT.h b/extensions/mqtt/processors/PublishMQTT.h index 2c2dfef114..d4aa572010 100644 --- a/extensions/mqtt/processors/PublishMQTT.h +++ b/extensions/mqtt/processors/PublishMQTT.h @@ -39,9 +39,10 @@ namespace org::apache::nifi::minifi::processors { class PublishMQTT : public processors::AbstractMQTTProcessor { public: - explicit PublishMQTT(std::string_view name, const utils::Identifier& uuid = {}) + explicit PublishMQTT(const std::string_view name, const utils::Identifier& uuid = {}) : processors::AbstractMQTTProcessor(name, uuid) { metrics_ = gsl::make_not_null(std::make_shared(*this, in_flight_message_counter_)); + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "PublishMQTT serializes FlowFile content as an MQTT payload, sending the message to the configured topic and broker."; @@ -191,7 +192,6 @@ class PublishMQTT : public processors::AbstractMQTTProcessor { bool retain_ = false; std::optional message_expiry_interval_; InFlightMessageCounter in_flight_message_counter_; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/opencv/CaptureRTSPFrame.h b/extensions/opencv/CaptureRTSPFrame.h index 2449565237..f2bcf72437 100644 --- a/extensions/opencv/CaptureRTSPFrame.h +++ b/extensions/opencv/CaptureRTSPFrame.h @@ -37,7 +37,8 @@ namespace org::apache::nifi::minifi::processors { class CaptureRTSPFrame final : public core::ProcessorImpl { public: explicit CaptureRTSPFrame(const std::string_view name, const utils::Identifier &uuid = {}) - : ProcessorImpl(name, uuid) { + : ProcessorImpl(std::move(name), uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "Captures a frame from the RTSP stream at specified intervals."; @@ -90,7 +91,6 @@ class CaptureRTSPFrame final : public core::ProcessorImpl { void notifyStop() override; private: - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); std::mutex mutex_; std::string rtsp_username_; std::string rtsp_password_; diff --git a/extensions/opencv/MotionDetector.h b/extensions/opencv/MotionDetector.h index e24eec5233..ddcb9e5d40 100644 --- a/extensions/opencv/MotionDetector.h +++ b/extensions/opencv/MotionDetector.h @@ -37,6 +37,7 @@ class MotionDetector final : public core::ProcessorImpl { public: explicit MotionDetector(const std::string_view name, const utils::Identifier &uuid = {}) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "Detect motion from captured images."; @@ -98,7 +99,6 @@ class MotionDetector final : public core::ProcessorImpl { private: bool detectAndDraw(cv::Mat &frame); - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); std::mutex mutex_; cv::Mat background_; cv::Mat bg_img_; diff --git a/extensions/procfs/processors/ProcFsMonitor.h b/extensions/procfs/processors/ProcFsMonitor.h index ae12031df9..da646ebc52 100644 --- a/extensions/procfs/processors/ProcFsMonitor.h +++ b/extensions/procfs/processors/ProcFsMonitor.h @@ -57,6 +57,7 @@ class ProcFsMonitor final : public core::ProcessorImpl { public: explicit ProcFsMonitor(const std::string_view name, utils::Identifier uuid = utils::Identifier()) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } ~ProcFsMonitor() override = default; @@ -141,7 +142,6 @@ class ProcFsMonitor final : public core::ProcessorImpl { ResultRelativeness result_relativeness_ = ResultRelativeness::Absolute; std::optional decimal_places_; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); ProcFs proc_fs_; diff --git a/extensions/python/ExecutePythonProcessor.h b/extensions/python/ExecutePythonProcessor.h index 0cbf2416e2..64947d3118 100644 --- a/extensions/python/ExecutePythonProcessor.h +++ b/extensions/python/ExecutePythonProcessor.h @@ -45,6 +45,7 @@ class ExecutePythonProcessor : public core::ProcessorImpl { processor_initialized_(false), python_dynamic_(false), reload_on_script_change_(true) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "Executes a script given the flow file and a process session. " @@ -153,8 +154,6 @@ class ExecutePythonProcessor : public core::ProcessorImpl { bool processor_initialized_; bool python_dynamic_; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); - std::string script_to_exec_; bool reload_on_script_change_; std::optional last_script_write_time_; diff --git a/extensions/script/ExecuteScript.h b/extensions/script/ExecuteScript.h index d6d241abdc..3b064155a2 100644 --- a/extensions/script/ExecuteScript.h +++ b/extensions/script/ExecuteScript.h @@ -46,8 +46,9 @@ enum class ScriptEngineOption { class ExecuteScript : public core::ProcessorImpl { public: - explicit ExecuteScript(std::string_view name, const utils::Identifier &uuid = {}) + explicit ExecuteScript(const std::string_view name, const utils::Identifier &uuid = {}) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "Executes a script given the flow file and a process session. " @@ -99,8 +100,6 @@ class ExecuteScript : public core::ProcessorImpl { } private: - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); - std::unique_ptr script_executor_; }; diff --git a/extensions/smb/FetchSmb.h b/extensions/smb/FetchSmb.h index 54c794e8a9..9b4f2cc71a 100644 --- a/extensions/smb/FetchSmb.h +++ b/extensions/smb/FetchSmb.h @@ -41,6 +41,7 @@ class FetchSmb final : public core::ProcessorImpl { public: explicit FetchSmb(const std::string_view name, const utils::Identifier& uuid = {}) : core::ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "Fetches files from a SMB Share. Designed to be used in tandem with ListSmb."; @@ -83,7 +84,6 @@ class FetchSmb final : public core::ProcessorImpl { private: std::shared_ptr smb_connection_controller_service_; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::extensions::smb diff --git a/extensions/smb/ListSmb.h b/extensions/smb/ListSmb.h index ae2f9def63..060cfdd250 100644 --- a/extensions/smb/ListSmb.h +++ b/extensions/smb/ListSmb.h @@ -39,8 +39,9 @@ namespace org::apache::nifi::minifi::extensions::smb { class ListSmb : public core::ProcessorImpl { public: - explicit ListSmb(std::string_view name, const utils::Identifier& uuid = {}) + explicit ListSmb(const std::string_view name, const utils::Identifier& uuid = {}) : core::ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "Retrieves a listing of files from an SMB share. For each file that is listed, " @@ -142,7 +143,6 @@ class ListSmb : public core::ProcessorImpl { private: std::shared_ptr createFlowFile(core::ProcessSession& session, const utils::ListedFile& listed_file); - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); std::filesystem::path input_directory_; std::shared_ptr smb_connection_controller_service_; std::unique_ptr state_manager_; diff --git a/extensions/smb/PutSmb.h b/extensions/smb/PutSmb.h index cb29d5c805..2a531a73f9 100644 --- a/extensions/smb/PutSmb.h +++ b/extensions/smb/PutSmb.h @@ -31,8 +31,9 @@ namespace org::apache::nifi::minifi::extensions::smb { class PutSmb final : public core::ProcessorImpl { public: - explicit PutSmb(const std::string_view name, const utils::Identifier& uuid = {}) + explicit PutSmb(const std::string_view name, const utils::Identifier& uuid = {}) : core::ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } enum class FileExistsResolutionStrategy { @@ -88,7 +89,6 @@ class PutSmb final : public core::ProcessorImpl { bool create_missing_dirs_ = true; FileExistsResolutionStrategy conflict_resolution_strategy_ = FileExistsResolutionStrategy::fail; std::shared_ptr smb_connection_controller_service_; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::extensions::smb diff --git a/extensions/splunk/PutSplunkHTTP.h b/extensions/splunk/PutSplunkHTTP.h index 8fbda961c8..831201aeb8 100644 --- a/extensions/splunk/PutSplunkHTTP.h +++ b/extensions/splunk/PutSplunkHTTP.h @@ -36,6 +36,7 @@ class PutSplunkHTTP final : public SplunkHECProcessor { public: explicit PutSplunkHTTP(std::string_view name, const utils::Identifier& uuid = {}) : SplunkHECProcessor(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } PutSplunkHTTP(const PutSplunkHTTP&) = delete; PutSplunkHTTP(PutSplunkHTTP&&) = delete; @@ -114,7 +115,6 @@ class PutSplunkHTTP final : public SplunkHECProcessor { std::optional source_; std::optional host_; std::optional index_; - std::shared_ptr logger_{core::logging::LoggerFactory::getLogger(uuid_)}; std::shared_ptr> client_queue_; }; diff --git a/extensions/standard-processors/modbus/FetchModbusTcp.h b/extensions/standard-processors/modbus/FetchModbusTcp.h index bcac234235..aec0714451 100644 --- a/extensions/standard-processors/modbus/FetchModbusTcp.h +++ b/extensions/standard-processors/modbus/FetchModbusTcp.h @@ -33,6 +33,7 @@ class FetchModbusTcp final : public core::ProcessorImpl { public: explicit FetchModbusTcp(const std::string_view name, const utils::Identifier& uuid = {}) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } EXTENSIONAPI static constexpr auto Description = "Processor able to read data from industrial PLCs using Modbus TCP/IP"; @@ -137,7 +138,6 @@ class FetchModbusTcp final : public core::ProcessorImpl { std::optional max_size_of_socket_send_buffer_; std::chrono::milliseconds timeout_duration_ = std::chrono::seconds(15); std::optional ssl_context_; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); std::shared_ptr record_set_writer_; }; } // namespace org::apache::nifi::minifi::modbus diff --git a/extensions/standard-processors/processors/AppendHostInfo.h b/extensions/standard-processors/processors/AppendHostInfo.h index 008717ace7..c256d1f0b0 100644 --- a/extensions/standard-processors/processors/AppendHostInfo.h +++ b/extensions/standard-processors/processors/AppendHostInfo.h @@ -41,8 +41,9 @@ class AppendHostInfo : public core::ProcessorImpl { static constexpr const char* REFRESH_POLICY_ON_TRIGGER = "On every trigger"; static constexpr const char* REFRESH_POLICY_ON_SCHEDULE = "On schedule"; - explicit AppendHostInfo(std::string_view name, const utils::Identifier& uuid = {}) + explicit AppendHostInfo(const std::string_view name, const utils::Identifier& uuid = {}) : core::ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } ~AppendHostInfo() override = default; @@ -91,7 +92,6 @@ class AppendHostInfo : public core::ProcessorImpl { private: std::shared_mutex shared_mutex_; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); std::string hostname_attribute_name_; std::string ipaddress_attribute_name_; std::optional interface_name_filter_; diff --git a/extensions/standard-processors/processors/AttributeRollingWindow.h b/extensions/standard-processors/processors/AttributeRollingWindow.h index 3a42afb551..3bdce33634 100644 --- a/extensions/standard-processors/processors/AttributeRollingWindow.h +++ b/extensions/standard-processors/processors/AttributeRollingWindow.h @@ -111,7 +111,6 @@ class AttributeRollingWindow final : public core::AbstractProcessor time_window_{}; std::optional window_length_{}; std::string attribute_name_prefix_; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/standard-processors/processors/AttributesToJSON.h b/extensions/standard-processors/processors/AttributesToJSON.h index 48cf6d82c4..30f77ddf84 100644 --- a/extensions/standard-processors/processors/AttributesToJSON.h +++ b/extensions/standard-processors/processors/AttributesToJSON.h @@ -116,8 +116,9 @@ class AttributesToJSON : public core::ProcessorImpl { ADD_COMMON_VIRTUAL_FUNCTIONS_FOR_PROCESSORS - explicit AttributesToJSON(std::string_view name, const utils::Identifier& uuid = {}) + explicit AttributesToJSON(const std::string_view name, const utils::Identifier& uuid = {}) : core::ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } void initialize() override; @@ -130,7 +131,6 @@ class AttributesToJSON : public core::ProcessorImpl { void addAttributeToJson(rapidjson::Document& document, const std::string& key, const std::optional& value) const; std::string buildAttributeJsonData(const core::FlowFile::AttributeMap& flowfile_attributes); - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); std::vector attribute_list_; std::optional attributes_regular_expression_; attributes_to_json::WriteDestination write_destination_; diff --git a/extensions/standard-processors/processors/DefragmentText.h b/extensions/standard-processors/processors/DefragmentText.h index 5f2da04e0b..b23ecd1232 100644 --- a/extensions/standard-processors/processors/DefragmentText.h +++ b/extensions/standard-processors/processors/DefragmentText.h @@ -59,8 +59,9 @@ namespace org::apache::nifi::minifi::processors { class DefragmentText : public core::ProcessorImpl { public: - explicit DefragmentText(std::string_view name, const utils::Identifier& uuid = {}) + explicit DefragmentText(const std::string_view name, const utils::Identifier& uuid = {}) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "DefragmentText splits and merges incoming flowfiles so cohesive messages are not split between them. " @@ -156,7 +157,6 @@ class DefragmentText : public core::ProcessorImpl { std::optional max_age_; std::optional max_size_; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); core::FlowFileStore flow_file_store_; std::unordered_map fragment_sources_; diff --git a/extensions/standard-processors/processors/ExtractText.h b/extensions/standard-processors/processors/ExtractText.h index 574581a3d2..6f0ee431b6 100644 --- a/extensions/standard-processors/processors/ExtractText.h +++ b/extensions/standard-processors/processors/ExtractText.h @@ -37,8 +37,9 @@ namespace org::apache::nifi::minifi::processors { class ExtractText : public core::ProcessorImpl { public: - explicit ExtractText(std::string_view name, const utils::Identifier& uuid = {}) + explicit ExtractText(const std::string_view name, const utils::Identifier& uuid = {}) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } // Default maximum bytes to read into an attribute @@ -117,9 +118,6 @@ class ExtractText : public core::ProcessorImpl { core::ProcessContext *ctx_; std::shared_ptr logger_; }; - - private: - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/standard-processors/processors/FetchFile.h b/extensions/standard-processors/processors/FetchFile.h index 7103a49509..54c7d08ff6 100644 --- a/extensions/standard-processors/processors/FetchFile.h +++ b/extensions/standard-processors/processors/FetchFile.h @@ -85,7 +85,8 @@ namespace org::apache::nifi::minifi::processors { class FetchFile final : public core::ProcessorImpl { public: explicit FetchFile(const std::string_view name, const utils::Identifier& uuid = {}) - : core::ProcessorImpl(name, uuid) { + : core::ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "Reads the contents of a file from disk and streams it into the contents of an incoming FlowFile. " @@ -176,7 +177,6 @@ class FetchFile final : public core::ProcessorImpl { fetch_file::MoveConflictStrategyOption move_conflict_strategy_{}; utils::LogUtils::LogLevelOption log_level_when_file_not_found_{}; utils::LogUtils::LogLevelOption log_level_when_permission_denied_{}; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/standard-processors/processors/GenerateFlowFile.h b/extensions/standard-processors/processors/GenerateFlowFile.h index ef013c8778..976b4de6c8 100644 --- a/extensions/standard-processors/processors/GenerateFlowFile.h +++ b/extensions/standard-processors/processors/GenerateFlowFile.h @@ -40,6 +40,7 @@ class GenerateFlowFile : public core::ProcessorImpl { public: explicit GenerateFlowFile(const std::string_view name, const utils::Identifier& uuid = {}) // NOLINT : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } ~GenerateFlowFile() override = default; @@ -123,8 +124,6 @@ class GenerateFlowFile : public core::ProcessorImpl { static Mode getMode(bool is_unique, bool is_text, bool has_custom_text, uint64_t file_size); static bool isUnique(Mode mode) { return mode == Mode::UniqueText || mode == Mode::UniqueByte; } static bool isText(Mode mode) { return mode == Mode::UniqueText || mode == Mode::CustomText || mode == Mode::NotUniqueText; } - - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/standard-processors/processors/GetFile.h b/extensions/standard-processors/processors/GetFile.h index 306fd514a7..83b7266585 100644 --- a/extensions/standard-processors/processors/GetFile.h +++ b/extensions/standard-processors/processors/GetFile.h @@ -83,9 +83,10 @@ class GetFileMetrics : public core::ProcessorMetricsImpl { class GetFile : public core::ProcessorImpl { public: - explicit GetFile(std::string_view name, const utils::Identifier& uuid = {}) + explicit GetFile(const std::string_view name, const utils::Identifier& uuid = {}) : ProcessorImpl(name, uuid) { metrics_ = gsl::make_not_null(std::make_shared(*this)); + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } ~GetFile() override = default; @@ -193,7 +194,6 @@ class GetFile : public core::ProcessorImpl { std::queue directory_listing_; mutable std::mutex directory_listing_mutex_; std::atomic> last_listing_time_{}; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/standard-processors/processors/GetTCP.h b/extensions/standard-processors/processors/GetTCP.h index d17a24274a..14e6db6571 100644 --- a/extensions/standard-processors/processors/GetTCP.h +++ b/extensions/standard-processors/processors/GetTCP.h @@ -46,8 +46,9 @@ namespace org::apache::nifi::minifi::processors { class GetTCP : public core::ProcessorImpl { public: - explicit GetTCP(std::string_view name, const utils::Identifier& uuid = {}) - : ProcessorImpl(name, uuid) { + explicit GetTCP(const std::string_view name, const utils::Identifier& uuid = {}) + : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } ~GetTCP() override { @@ -185,7 +186,6 @@ class GetTCP : public core::ProcessorImpl { std::optional client_; size_t max_batch_size_{500}; std::thread client_thread_; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/standard-processors/processors/HashContent.h b/extensions/standard-processors/processors/HashContent.h index 865f84e0f3..51711ed497 100644 --- a/extensions/standard-processors/processors/HashContent.h +++ b/extensions/standard-processors/processors/HashContent.h @@ -136,8 +136,9 @@ static const std::map::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "HashContent calculates the checksum of the content of the flowfile and adds it as an attribute. " @@ -178,7 +179,6 @@ class HashContent : public core::ProcessorImpl { void initialize() override; private: - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); std::function&)> algorithm_ = SHA256Hash; std::string attrKey_; bool failOnEmpty_{}; diff --git a/extensions/standard-processors/processors/InvokeHTTP.h b/extensions/standard-processors/processors/InvokeHTTP.h index 13406a8c5f..4e87421c30 100644 --- a/extensions/standard-processors/processors/InvokeHTTP.h +++ b/extensions/standard-processors/processors/InvokeHTTP.h @@ -112,8 +112,9 @@ class InvokeHTTP : public core::ProcessorImpl { EXTENSIONAPI static constexpr std::string_view REQUEST_URL = "invokehttp.request.url"; EXTENSIONAPI static constexpr std::string_view TRANSACTION_ID = "invokehttp.tx.id"; - explicit InvokeHTTP(std::string_view name, const utils::Identifier& uuid = {}) + explicit InvokeHTTP(const std::string_view name, const utils::Identifier& uuid = {}) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); setTriggerWhenEmpty(true); } @@ -351,12 +352,7 @@ class InvokeHTTP : public core::ProcessorImpl { http::HTTPProxy proxy_{}; bool follow_redirects_ = false; std::optional content_type_; - - invoke_http::InvalidHTTPHeaderFieldHandlingOption invalid_http_header_field_handling_strategy_{}; - - std::shared_ptr logger_{core::logging::LoggerFactory::getLogger(uuid_)}; - std::unique_ptr client_queue_; }; diff --git a/extensions/standard-processors/processors/JoltTransformJSON.h b/extensions/standard-processors/processors/JoltTransformJSON.h index dc8619da40..478ee6856f 100644 --- a/extensions/standard-processors/processors/JoltTransformJSON.h +++ b/extensions/standard-processors/processors/JoltTransformJSON.h @@ -37,8 +37,10 @@ namespace org::apache::nifi::minifi::processors { class JoltTransformJSON : public core::ProcessorImpl { public: - explicit JoltTransformJSON(std::string_view name, const utils::Identifier& uuid = {}) - : ProcessorImpl(name, uuid) {} + explicit JoltTransformJSON(const std::string_view name, const utils::Identifier& uuid = {}) + : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); + } EXTENSIONAPI static constexpr const char* Description = "Applies a list of Jolt specifications to the flowfile JSON payload. A new FlowFile is created " @@ -84,7 +86,6 @@ class JoltTransformJSON : public core::ProcessorImpl { private: jolt_transform_json::JoltTransform transform_; std::optional spec_; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/standard-processors/processors/ListFile.h b/extensions/standard-processors/processors/ListFile.h index da8642166b..968ee38ab4 100644 --- a/extensions/standard-processors/processors/ListFile.h +++ b/extensions/standard-processors/processors/ListFile.h @@ -38,8 +38,9 @@ namespace org::apache::nifi::minifi::processors { class ListFile : public core::ProcessorImpl { public: - explicit ListFile(std::string_view name, const utils::Identifier& uuid = {}) - : core::ProcessorImpl(name, uuid) { + explicit ListFile(const std::string_view name, const utils::Identifier& uuid = {}) + : core::ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "Retrieves a listing of files from the local filesystem. For each file that is listed, " @@ -147,7 +148,6 @@ class ListFile : public core::ProcessorImpl { private: std::shared_ptr createFlowFile(core::ProcessSession& session, const utils::ListedFile& listed_file); - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); std::filesystem::path input_directory_; std::unique_ptr state_manager_; bool recurse_subdirectories_ = true; diff --git a/extensions/standard-processors/processors/LogAttribute.h b/extensions/standard-processors/processors/LogAttribute.h index 2cb4ba62d6..d32983a7b4 100644 --- a/extensions/standard-processors/processors/LogAttribute.h +++ b/extensions/standard-processors/processors/LogAttribute.h @@ -40,6 +40,7 @@ class LogAttribute : public core::ProcessorImpl { public: explicit LogAttribute(const std::string_view name, const utils::Identifier& uuid = {}) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); logger_->set_max_log_size(-1); } ~LogAttribute() override = default; @@ -111,7 +112,6 @@ class LogAttribute : public core::ProcessorImpl { uint64_t flowfiles_to_log_{1}; bool hexencode_{false}; uint32_t max_line_length_{80}; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); core::logging::LOG_LEVEL log_level_{core::logging::LOG_LEVEL::info}; std::string dash_line_ = "--------------------------------------------------"; bool log_payload_ = false; diff --git a/extensions/standard-processors/processors/PutFile.h b/extensions/standard-processors/processors/PutFile.h index 227ac5582a..82a8d2ef68 100644 --- a/extensions/standard-processors/processors/PutFile.h +++ b/extensions/standard-processors/processors/PutFile.h @@ -36,8 +36,9 @@ namespace org::apache::nifi::minifi::processors { class PutFile : public core::ProcessorImpl { public: - explicit PutFile(std::string_view name, const utils::Identifier& uuid = {}) + explicit PutFile(const std::string_view name, const utils::Identifier& uuid = {}) : core::ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } ~PutFile() override = default; @@ -119,7 +120,6 @@ class PutFile : public core::ProcessorImpl { bool directoryIsFull(const std::filesystem::path& directory) const; std::optional getDestinationPath(core::ProcessContext& context, const std::shared_ptr& flow_file); void putFile(core::ProcessSession& session, const std::shared_ptr& flow_file, const std::filesystem::path& dest_file); - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); static std::shared_ptr id_generator_; #ifndef WIN32 diff --git a/extensions/standard-processors/processors/PutTCP.cpp b/extensions/standard-processors/processors/PutTCP.cpp index d5756bfcc1..781601832e 100644 --- a/extensions/standard-processors/processors/PutTCP.cpp +++ b/extensions/standard-processors/processors/PutTCP.cpp @@ -37,8 +37,10 @@ namespace org::apache::nifi::minifi::processors { constexpr size_t chunk_size = 1024; -PutTCP::PutTCP(const std::string& name, const utils::Identifier& uuid) - : ProcessorImpl(name, uuid) {} +PutTCP::PutTCP(const std::string_view name, const utils::Identifier& uuid) + : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); +} PutTCP::~PutTCP() = default; diff --git a/extensions/standard-processors/processors/PutTCP.h b/extensions/standard-processors/processors/PutTCP.h index 6ea2ecfe21..a5649fc201 100644 --- a/extensions/standard-processors/processors/PutTCP.h +++ b/extensions/standard-processors/processors/PutTCP.h @@ -125,7 +125,7 @@ class PutTCP final : public core::ProcessorImpl { ADD_COMMON_VIRTUAL_FUNCTIONS_FOR_PROCESSORS - explicit PutTCP(const std::string& name, const utils::Identifier& uuid = {}); + explicit PutTCP(const std::string_view name, const utils::Identifier& uuid = {}); PutTCP(const PutTCP&) = delete; PutTCP(PutTCP&&) = delete; PutTCP& operator=(const PutTCP&) = delete; @@ -157,7 +157,6 @@ class PutTCP final : public core::ProcessorImpl { std::optional max_size_of_socket_send_buffer_; std::chrono::milliseconds timeout_duration_ = std::chrono::seconds(15); std::optional ssl_context_; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/standard-processors/processors/RetryFlowFile.h b/extensions/standard-processors/processors/RetryFlowFile.h index 58651acd92..d24575ed6a 100644 --- a/extensions/standard-processors/processors/RetryFlowFile.h +++ b/extensions/standard-processors/processors/RetryFlowFile.h @@ -41,8 +41,10 @@ namespace org::apache::nifi::minifi::processors { class RetryFlowFile : public core::ProcessorImpl { public: - explicit RetryFlowFile(std::string_view name, const utils::Identifier& uuid = {}) - : ProcessorImpl(name, uuid) {} + explicit RetryFlowFile(const std::string_view name, const utils::Identifier& uuid = {}) + : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); + } ~RetryFlowFile() override = default; // ReuseMode allowed values @@ -156,8 +158,6 @@ class RetryFlowFile : public core::ProcessorImpl { bool fail_on_non_numerical_overwrite_ = false; // The real default value is set by the default on the FailOnNonNumericalOverwrite property std::string reuse_mode_; std::vector exceeded_flowfile_attribute_keys_; - - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/standard-processors/processors/RouteOnAttribute.h b/extensions/standard-processors/processors/RouteOnAttribute.h index 4ca46da794..a31460d275 100644 --- a/extensions/standard-processors/processors/RouteOnAttribute.h +++ b/extensions/standard-processors/processors/RouteOnAttribute.h @@ -34,8 +34,9 @@ namespace org::apache::nifi::minifi::processors { class RouteOnAttribute : public core::ProcessorImpl { public: - explicit RouteOnAttribute(std::string_view name, const utils::Identifier& uuid = {}) + explicit RouteOnAttribute(const std::string_view name, const utils::Identifier& uuid = {}) : core::ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "Routes FlowFiles based on their Attributes using the Attribute Expression Language.\n\n" @@ -61,7 +62,6 @@ class RouteOnAttribute : public core::ProcessorImpl { void initialize() override; private: - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); std::map route_properties_; std::map route_rels_; }; diff --git a/extensions/standard-processors/processors/SegmentContent.h b/extensions/standard-processors/processors/SegmentContent.h index 321bf29f38..342ebed4bb 100644 --- a/extensions/standard-processors/processors/SegmentContent.h +++ b/extensions/standard-processors/processors/SegmentContent.h @@ -34,7 +34,9 @@ namespace org::apache::nifi::minifi::processors { class SegmentContent final : public core::ProcessorImpl { public: - explicit SegmentContent(const std::string_view name, const utils::Identifier& uuid = {}) : ProcessorImpl(name, uuid) {} + explicit SegmentContent(const std::string_view name, const utils::Identifier& uuid = {}) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); + } EXTENSIONAPI static constexpr auto Description = "Segments a FlowFile into multiple smaller segments on byte boundaries."; @@ -71,9 +73,6 @@ class SegmentContent final : public core::ProcessorImpl { void onSchedule(core::ProcessContext& context, core::ProcessSessionFactory& session_factory) override; void onTrigger(core::ProcessContext& context, core::ProcessSession& session) override; void initialize() override; - - private: - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/standard-processors/processors/SplitContent.h b/extensions/standard-processors/processors/SplitContent.h index 70789a24cf..566d0dff7c 100644 --- a/extensions/standard-processors/processors/SplitContent.h +++ b/extensions/standard-processors/processors/SplitContent.h @@ -34,7 +34,9 @@ namespace org::apache::nifi::minifi::processors { class SplitContent final : public core::ProcessorImpl { public: - explicit SplitContent(const std::string_view name, const utils::Identifier& uuid = {}) : ProcessorImpl(name, uuid) {} + explicit SplitContent(const std::string_view name, const utils::Identifier& uuid = {}) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); + } using size_type = std::vector::size_type; enum class ByteSequenceFormat { Hexadecimal, Text }; @@ -124,7 +126,6 @@ class SplitContent final : public core::ProcessorImpl { std::optional byte_sequence_matcher_; bool keep_byte_sequence = false; ByteSequenceLocation byte_sequence_location_ = ByteSequenceLocation::Trailing; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/standard-processors/processors/SplitRecord.h b/extensions/standard-processors/processors/SplitRecord.h index 27bdd7c93c..510a8f44ce 100644 --- a/extensions/standard-processors/processors/SplitRecord.h +++ b/extensions/standard-processors/processors/SplitRecord.h @@ -89,8 +89,6 @@ class SplitRecord final : public core::AbstractProcessor { std::shared_ptr record_set_reader_; std::shared_ptr record_set_writer_; - - std::shared_ptr logger_{core::logging::LoggerFactory::getLogger(uuid_)}; }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/standard-processors/processors/SplitText.h b/extensions/standard-processors/processors/SplitText.h index 0d40a6e9c1..c1a9e971fd 100644 --- a/extensions/standard-processors/processors/SplitText.h +++ b/extensions/standard-processors/processors/SplitText.h @@ -88,8 +88,9 @@ class LineReader { class SplitText : public core::ProcessorImpl { public: - explicit SplitText(std::string_view name, const utils::Identifier& uuid = {}) + explicit SplitText(const std::string_view name, const utils::Identifier& uuid = {}) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "Splits a text file into multiple smaller text files on line boundaries limited by maximum number of lines or total size of fragment. " @@ -174,7 +175,6 @@ class SplitText : public core::ProcessorImpl { private: SplitTextConfiguration split_text_config_; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/standard-processors/processors/TailFile.h b/extensions/standard-processors/processors/TailFile.h index 9069c2f13d..174d809f80 100644 --- a/extensions/standard-processors/processors/TailFile.h +++ b/extensions/standard-processors/processors/TailFile.h @@ -104,8 +104,9 @@ enum class Mode { class TailFile : public core::ProcessorImpl { public: - explicit TailFile(std::string_view name, const utils::Identifier& uuid = {}) + explicit TailFile(const std::string_view name, const utils::Identifier& uuid = {}) : core::ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } ~TailFile() override = default; @@ -283,7 +284,6 @@ class TailFile : public core::ProcessorImpl { controllers::AttributeProviderService* attribute_provider_service_ = nullptr; std::unordered_map extra_attributes_; std::optional batch_size_; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/standard-processors/processors/UpdateAttribute.h b/extensions/standard-processors/processors/UpdateAttribute.h index 7f4407ca51..694360c66e 100644 --- a/extensions/standard-processors/processors/UpdateAttribute.h +++ b/extensions/standard-processors/processors/UpdateAttribute.h @@ -35,8 +35,9 @@ namespace org::apache::nifi::minifi::processors { class UpdateAttribute : public core::ProcessorImpl { public: - UpdateAttribute(std::string_view name, const utils::Identifier& uuid = {}) // NOLINT + explicit UpdateAttribute(const std::string_view name, const utils::Identifier& uuid = {}) : core::ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "This processor updates the attributes of a FlowFile using properties that are added by the user. " @@ -60,7 +61,6 @@ class UpdateAttribute : public core::ProcessorImpl { void initialize() override; private: - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); std::vector attributes_; }; diff --git a/extensions/standard-processors/tests/unit/ProcessorTests.cpp b/extensions/standard-processors/tests/unit/ProcessorTests.cpp index 4f389fd30e..4eb8c50c01 100644 --- a/extensions/standard-processors/tests/unit/ProcessorTests.cpp +++ b/extensions/standard-processors/tests/unit/ProcessorTests.cpp @@ -51,6 +51,7 @@ #include "unit/TestUtils.h" #include "io/BufferStream.h" #include "fmt/format.h" +#include "processors/TailFile.h" TEST_CASE("Test Creation of GetFile", "[getfileCreate]") { TestController testController; @@ -794,6 +795,7 @@ TEST_CASE("isSingleThreaded - one thread for a single threaded processor", "[isS TEST_CASE("isSingleThreaded - two threads for a single threaded processor", "[isSingleThreaded]") { TestController testController; LogTestController::getInstance().setDebug(); + LogTestController::getInstance().setDebug(); std::shared_ptr plan = testController.createPlan(); auto processor = plan->addProcessor("TailFile", "myProc"); diff --git a/extensions/systemd/ConsumeJournald.cpp b/extensions/systemd/ConsumeJournald.cpp index 073746cdc6..f4a4e52b5a 100644 --- a/extensions/systemd/ConsumeJournald.cpp +++ b/extensions/systemd/ConsumeJournald.cpp @@ -33,8 +33,9 @@ namespace org::apache::nifi::minifi::extensions::systemd { namespace chr = std::chrono; ConsumeJournald::ConsumeJournald(const std::string_view name, const utils::Identifier &id, std::unique_ptr&& libwrapper) - :core::ProcessorImpl{name, id}, libwrapper_{std::move(libwrapper)} -{} + : core::ProcessorImpl{name, id}, libwrapper_{std::move(libwrapper)} { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); +} void ConsumeJournald::initialize() { setSupportedProperties(Properties); @@ -109,6 +110,7 @@ void ConsumeJournald::onSchedule(core::ProcessContext& context, core::ProcessSes } void ConsumeJournald::onTrigger(core::ProcessContext&, core::ProcessSession& session) { + gsl_Expects(state_manager_); if (!running_.load(std::memory_order_acquire)) return; auto cursor_and_messages = getCursorAndMessageBatch().get(); auto messages = std::move(cursor_and_messages.second); diff --git a/extensions/systemd/ConsumeJournald.h b/extensions/systemd/ConsumeJournald.h index a12e6c9114..8af2118f0c 100644 --- a/extensions/systemd/ConsumeJournald.h +++ b/extensions/systemd/ConsumeJournald.h @@ -145,8 +145,7 @@ class ConsumeJournald final : public core::ProcessorImpl { std::string getCursor() const; std::atomic running_{false}; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); - core::StateManager* state_manager_; + core::StateManager* state_manager_ = nullptr; std::unique_ptr libwrapper_; std::unique_ptr worker_; std::unique_ptr journal_; diff --git a/extensions/test-processors/KamikazeProcessor.h b/extensions/test-processors/KamikazeProcessor.h index 8b90d78781..196d8ea3c4 100644 --- a/extensions/test-processors/KamikazeProcessor.h +++ b/extensions/test-processors/KamikazeProcessor.h @@ -39,8 +39,9 @@ class KamikazeProcessor : public core::ProcessorImpl { EXTENSIONAPI static const std::string OnTriggerLogStr; EXTENSIONAPI static const std::string OnUnScheduleLogStr; - explicit KamikazeProcessor(std::string_view name, const utils::Identifier& uuid = utils::Identifier()) + explicit KamikazeProcessor(const std::string_view name, const utils::Identifier& uuid = utils::Identifier()) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "This processor can throw exceptions in onTrigger and onSchedule calls based on configuration. Only for testing purposes."; @@ -79,7 +80,6 @@ class KamikazeProcessor : public core::ProcessorImpl { private: bool _throwInOnTrigger = false; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/test-processors/LogOnDestructionProcessor.h b/extensions/test-processors/LogOnDestructionProcessor.h index 0d03c2c25f..2f808d815d 100644 --- a/extensions/test-processors/LogOnDestructionProcessor.h +++ b/extensions/test-processors/LogOnDestructionProcessor.h @@ -29,8 +29,9 @@ namespace org::apache::nifi::minifi::processors { class LogOnDestructionProcessor : public core::ProcessorImpl { public: - explicit LogOnDestructionProcessor(std::string_view name, const utils::Identifier& uuid = utils::Identifier()) - : ProcessorImpl(name, uuid) { + explicit LogOnDestructionProcessor(const std::string_view name, const utils::Identifier& uuid = utils::Identifier()) + : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } ~LogOnDestructionProcessor() override { @@ -45,9 +46,6 @@ class LogOnDestructionProcessor : public core::ProcessorImpl { EXTENSIONAPI static constexpr core::annotation::Input InputRequirement = core::annotation::Input::INPUT_ALLOWED; EXTENSIONAPI static constexpr bool IsSingleThreaded = false; ADD_COMMON_VIRTUAL_FUNCTIONS_FOR_PROCESSORS - - private: - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/windows-event-log/ConsumeWindowsEventLog.cpp b/extensions/windows-event-log/ConsumeWindowsEventLog.cpp index 62a7743f40..0343d36a5d 100644 --- a/extensions/windows-event-log/ConsumeWindowsEventLog.cpp +++ b/extensions/windows-event-log/ConsumeWindowsEventLog.cpp @@ -61,9 +61,9 @@ namespace org::apache::nifi::minifi::processors { const int EVT_NEXT_TIMEOUT_MS = 500; -ConsumeWindowsEventLog::ConsumeWindowsEventLog(const std::string& name, const utils::Identifier& uuid) - : core::ProcessorImpl(name, uuid), - logger_(core::logging::LoggerFactory::getLogger(uuid_)) { +ConsumeWindowsEventLog::ConsumeWindowsEventLog(const std::string_view name, const utils::Identifier& uuid) + : core::ProcessorImpl(name, uuid), + logger_(core::logging::LoggerFactory::getLogger(uuid_)) { char buff[MAX_COMPUTERNAME_LENGTH + 1]; DWORD size = sizeof(buff); if (GetComputerName(buff, &size)) { diff --git a/extensions/windows-event-log/ConsumeWindowsEventLog.h b/extensions/windows-event-log/ConsumeWindowsEventLog.h index e939d627f7..4821d60d79 100644 --- a/extensions/windows-event-log/ConsumeWindowsEventLog.h +++ b/extensions/windows-event-log/ConsumeWindowsEventLog.h @@ -236,7 +236,6 @@ class ConsumeWindowsEventLog : public core::ProcessorImpl { void addMatchedFieldsAsAttributes(const cwel::EventRender &eventRender, core::ProcessSession &session, const std::shared_ptr &flowFile) const; - std::shared_ptr logger_; core::StateManager* state_manager_{nullptr}; wel::METADATA_NAMES header_names_; std::optional header_delimiter_; diff --git a/libminifi/test/libtest/unit/ReadFromFlowFileTestProcessor.h b/libminifi/test/libtest/unit/ReadFromFlowFileTestProcessor.h index 869c48bb4c..a1fdd7f288 100644 --- a/libminifi/test/libtest/unit/ReadFromFlowFileTestProcessor.h +++ b/libminifi/test/libtest/unit/ReadFromFlowFileTestProcessor.h @@ -40,8 +40,9 @@ class ReadFromFlowFileTestProcessor : public core::ProcessorImpl { static constexpr const char* ON_TRIGGER_LOG_STR = "ReadFromFlowFileTestProcessor::onTrigger executed"; static constexpr const char* ON_UNSCHEDULE_LOG_STR = "ReadFromFlowFileTestProcessor::onUnSchedule executed"; - explicit ReadFromFlowFileTestProcessor(std::string_view name, const utils::Identifier& uuid = utils::Identifier()) + explicit ReadFromFlowFileTestProcessor(const std::string_view name, const utils::Identifier& uuid = utils::Identifier()) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } static constexpr const char* Description = "ReadFromFlowFileTestProcessor (only for testing purposes)"; @@ -90,7 +91,6 @@ class ReadFromFlowFileTestProcessor : public core::ProcessorImpl { std::map attributes_; }; bool clear_on_trigger_ = true; - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); std::vector flow_files_read_; }; diff --git a/libminifi/test/libtest/unit/WriteToFlowFileTestProcessor.h b/libminifi/test/libtest/unit/WriteToFlowFileTestProcessor.h index 3949be1808..6f0b13ba9b 100644 --- a/libminifi/test/libtest/unit/WriteToFlowFileTestProcessor.h +++ b/libminifi/test/libtest/unit/WriteToFlowFileTestProcessor.h @@ -38,8 +38,9 @@ class WriteToFlowFileTestProcessor : public core::ProcessorImpl { static constexpr const char* ON_TRIGGER_LOG_STR = "WriteToFlowFileTestProcessor::onTrigger executed"; static constexpr const char* ON_UNSCHEDULE_LOG_STR = "WriteToFlowFileTestProcessor::onUnSchedule executed"; - explicit WriteToFlowFileTestProcessor(std::string_view name, const utils::Identifier& uuid = utils::Identifier()) + explicit WriteToFlowFileTestProcessor(const std::string_view name, const utils::Identifier& uuid = utils::Identifier()) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory::getLogger(uuid_); } static constexpr const char* Description = "WriteToFlowFileTestProcessor (only for testing purposes)"; @@ -67,7 +68,6 @@ class WriteToFlowFileTestProcessor : public core::ProcessorImpl { } private: - std::shared_ptr logger_ = core::logging::LoggerFactory::getLogger(uuid_); std::string content_; };