This is an automated email from the ASF dual-hosted git repository. martinzink pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
commit 9928fa7e99244437d4af1bfe916640f6da67ed8a Author: Gabor Gyimesi <[email protected]> AuthorDate: Mon Apr 14 16:33:52 2025 +0200 MINIFICPP-2512 Only use a single logger per processor Closes #1918 Signed-off-by: Martin Zink <[email protected]> --- 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 +- extensions/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 +- extensions/standard-processors/processors/AppendHostInfo.h | 4 ++-- .../standard-processors/processors/AttributeRollingWindow.h | 1 - extensions/standard-processors/processors/AttributesToJSON.h | 4 ++-- extensions/standard-processors/processors/DefragmentText.h | 4 ++-- extensions/standard-processors/processors/ExtractText.h | 6 ++---- extensions/standard-processors/processors/FetchFile.h | 4 ++-- extensions/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 ++------ extensions/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 ++++---- extensions/standard-processors/processors/RouteOnAttribute.h | 4 ++-- extensions/standard-processors/processors/SegmentContent.h | 5 +++-- 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 ++-- extensions/standard-processors/processors/UpdateAttribute.h | 6 ++---- extensions/standard-processors/tests/unit/ProcessorTests.cpp | 2 ++ extensions/systemd/ConsumeJournald.cpp | 6 ++++-- extensions/systemd/ConsumeJournald.h | 1 - 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 | 3 +-- libminifi/test/libtest/unit/ReadFromFlowFileTestProcessor.h | 4 ++-- libminifi/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 d5405577c..27a0966f2 100644 --- a/extension-utils/include/core/AbstractProcessor.h +++ b/extension-utils/include/core/AbstractProcessor.h @@ -26,12 +26,16 @@ #include "core/PropertyDefinition.h" #include "minifi-cpp/core/RelationshipDefinition.h" #include "utils/StringUtils.h" +#include "core/logging/LoggerFactory.h" namespace org::apache::nifi::minifi::core { template<typename ProcessorT> 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<ProcessorT>::getLogger(uuid_); + } void initialize() final { static_assert(std::is_same_v<typename decltype(ProcessorT::Properties)::value_type, PropertyReference>); diff --git a/extensions/bustache/ApplyTemplate.h b/extensions/bustache/ApplyTemplate.h index e06e0259f..f1390856a 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<ApplyTemplate>::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<core::logging::Logger> logger_ = core::logging::LoggerFactory<ApplyTemplate>::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/civetweb/processors/ListenHTTP.h b/extensions/civetweb/processors/ListenHTTP.h index 1f2b9e90d..ce47ab97c 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<ListenHTTP>::getLogger(uuid_); callbacks_.log_message = &logMessage; callbacks_.log_access = &logAccess; } @@ -285,7 +286,6 @@ class ListenHTTP : public core::ProcessorImpl { return handler_ ? handler_->requestCount() : 0; } - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<ListenHTTP>::getLogger(uuid_); CivetCallbacks callbacks_; std::unique_ptr<CivetServer> server_; std::unique_ptr<Handler> handler_; diff --git a/extensions/couchbase/processors/GetCouchbaseKey.h b/extensions/couchbase/processors/GetCouchbaseKey.h index 609db61cf..175b25dd5 100644 --- a/extensions/couchbase/processors/GetCouchbaseKey.h +++ b/extensions/couchbase/processors/GetCouchbaseKey.h @@ -111,7 +111,6 @@ class GetCouchbaseKey final : public core::AbstractProcessor<GetCouchbaseKey> { private: std::shared_ptr<controllers::CouchbaseClusterService> couchbase_cluster_service_; CouchbaseValueType document_type_ = CouchbaseValueType::Json; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<GetCouchbaseKey>::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::couchbase::processors diff --git a/extensions/couchbase/processors/PutCouchbaseKey.h b/extensions/couchbase/processors/PutCouchbaseKey.h index 3bb628a62..7a5c77b53 100644 --- a/extensions/couchbase/processors/PutCouchbaseKey.h +++ b/extensions/couchbase/processors/PutCouchbaseKey.h @@ -159,7 +159,6 @@ class PutCouchbaseKey final : public core::AbstractProcessor<PutCouchbaseKey> { 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<core::logging::Logger> logger_ = core::logging::LoggerFactory<PutCouchbaseKey>::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::couchbase::processors diff --git a/extensions/elasticsearch/PostElasticsearch.h b/extensions/elasticsearch/PostElasticsearch.h index 76da0f1ac..1ea1e51f7 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<PostElasticsearch>::getLogger(uuid_); } ~PostElasticsearch() override = default; @@ -118,7 +119,6 @@ class PostElasticsearch : public core::ProcessorImpl { std::string host_url_; std::shared_ptr<ElasticsearchCredentialsControllerService> credentials_service_; http::HTTPClient client_; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<PostElasticsearch>::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::extensions::elasticsearch diff --git a/extensions/execute-process/ExecuteProcess.h b/extensions/execute-process/ExecuteProcess.h index 2abd0b529..0deba66c9 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<ExecuteProcess>::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<core::FlowFile>& flow_file, std::span<const char> buffer) const; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<ExecuteProcess>::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 64ea72723..31a70cc0d 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<CollectKubernetesPodMetrics>::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<std::shared_ptr<core::logging::Logger>> logger_ = gsl::make_not_null(core::logging::LoggerFactory<CollectKubernetesPodMetrics>::getLogger(uuid_)); std::shared_ptr<controllers::KubernetesControllerService> kubernetes_controller_service_; }; diff --git a/extensions/libarchive/BinFiles.h b/extensions/libarchive/BinFiles.h index 45b828578..f4b5407bb 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<core::logging::Logger> logger_{core::logging::LoggerFactory<BinFiles>::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 221e57128..a1a2666b1 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<CompressContent>::getLogger(uuid_); } ~CompressContent() override = default; @@ -214,7 +215,6 @@ class CompressContent : public core::ProcessorImpl { void processFlowFile(const std::shared_ptr<core::FlowFile>& flowFile, core::ProcessSession& session); - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<CompressContent>::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 551802a32..89be2362c 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<FocusArchiveEntry>::getLogger(uuid_); } ~FocusArchiveEntry() override = default; @@ -80,7 +81,6 @@ class FocusArchiveEntry : public core::ProcessorImpl { }; private: - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<FocusArchiveEntry>::getLogger(uuid_); static std::shared_ptr<utils::IdGenerator> id_generator_; }; diff --git a/extensions/libarchive/ManipulateArchive.h b/extensions/libarchive/ManipulateArchive.h index 712965b3d..769f6399f 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<ManipulateArchive>::getLogger(uuid_); } ~ManipulateArchive() override = default; @@ -91,7 +92,6 @@ class ManipulateArchive : public core::ProcessorImpl { void initialize() override; private: - std::shared_ptr<Logger> logger_ = core::logging::LoggerFactory<ManipulateArchive>::getLogger(uuid_); std::string before_, after_, operation_, destination_, targetEntry_; }; diff --git a/extensions/libarchive/MergeContent.h b/extensions/libarchive/MergeContent.h index f54046617..398eea6cf 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<MergeContent>::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<core::logging::Logger> logger_ = core::logging::LoggerFactory<MergeContent>::getLogger(uuid_); std::string mergeStrategy_; std::string mergeFormat_; std::string correlationAttributeName_; diff --git a/extensions/libarchive/UnfocusArchiveEntry.h b/extensions/libarchive/UnfocusArchiveEntry.h index db6cd738a..fa662b6fb 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<UnfocusArchiveEntry>::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> logger_ = core::logging::LoggerFactory<UnfocusArchiveEntry>::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/mqtt/processors/AbstractMQTTProcessor.h b/extensions/mqtt/processors/AbstractMQTTProcessor.h index 1c37abe7b..5eea11b4a 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<core::logging::Logger> logger_ = core::logging::LoggerFactory<AbstractMQTTProcessor>::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/mqtt/processors/ConsumeMQTT.h b/extensions/mqtt/processors/ConsumeMQTT.h index a91cef8aa..2f9ba7eff 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<ConsumeMQTT>::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<uint16_t, std::string> alias_to_topic_; moodycamel::ConcurrentQueue<SmartMessage> queue_; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<ConsumeMQTT>::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/mqtt/processors/PublishMQTT.h b/extensions/mqtt/processors/PublishMQTT.h index 81fd4b9ce..398216751 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<PublishMQTTMetrics>(*this, in_flight_message_counter_)); + logger_ = core::logging::LoggerFactory<PublishMQTT>::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<std::chrono::seconds> message_expiry_interval_; InFlightMessageCounter in_flight_message_counter_; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<PublishMQTT>::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/opencv/CaptureRTSPFrame.h b/extensions/opencv/CaptureRTSPFrame.h index 244956523..f2bcf7243 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<CaptureRTSPFrame>::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<core::logging::Logger> logger_ = core::logging::LoggerFactory<CaptureRTSPFrame>::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 ffa0c3334..d2b9036e8 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<MotionDetector>::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "Detect motion from captured images."; @@ -99,7 +100,6 @@ class MotionDetector final : public core::ProcessorImpl { private: bool detectAndDraw(cv::Mat &frame); - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<MotionDetector>::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 36ff656a6..63764d0ed 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<ProcFsMonitor>::getLogger(uuid_); } ~ProcFsMonitor() override = default; @@ -140,7 +141,6 @@ class ProcFsMonitor final : public core::ProcessorImpl { ResultRelativeness result_relativeness_ = ResultRelativeness::Absolute; std::optional<uint8_t> decimal_places_; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<ProcFsMonitor>::getLogger(uuid_); ProcFs proc_fs_; diff --git a/extensions/python/ExecutePythonProcessor.h b/extensions/python/ExecutePythonProcessor.h index 4e56883e8..9c0138565 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<ExecutePythonProcessor>::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "Executes a script given the flow file and a process session. " @@ -154,8 +155,6 @@ class ExecutePythonProcessor : public core::ProcessorImpl { bool processor_initialized_; bool python_dynamic_; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<ExecutePythonProcessor>::getLogger(uuid_); - std::string script_to_exec_; bool reload_on_script_change_; std::optional<std::chrono::file_clock::time_point> last_script_write_time_; diff --git a/extensions/script/ExecuteScript.h b/extensions/script/ExecuteScript.h index d6d241abd..3b064155a 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<ExecuteScript>::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<core::logging::Logger> logger_ = core::logging::LoggerFactory<ExecuteScript>::getLogger(uuid_); - std::unique_ptr<extensions::script::ScriptExecutor> script_executor_; }; diff --git a/extensions/smb/FetchSmb.h b/extensions/smb/FetchSmb.h index c69616366..8f84d361d 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<FetchSmb>::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "Fetches files from a SMB Share. Designed to be used in tandem with ListSmb."; @@ -84,7 +85,6 @@ class FetchSmb final : public core::ProcessorImpl { private: std::shared_ptr<SmbConnectionControllerService> smb_connection_controller_service_; size_t buffer_size_{}; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<FetchSmb>::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::extensions::smb diff --git a/extensions/smb/ListSmb.h b/extensions/smb/ListSmb.h index 3c7ad2927..3e613487e 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<ListSmb>::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<core::FlowFile> createFlowFile(core::ProcessSession& session, const utils::ListedFile& listed_file); - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<ListSmb>::getLogger(uuid_); std::filesystem::path input_directory_; std::shared_ptr<SmbConnectionControllerService> smb_connection_controller_service_; std::unique_ptr<minifi::utils::ListingStateManager> state_manager_; diff --git a/extensions/smb/PutSmb.h b/extensions/smb/PutSmb.h index cb29d5c80..2a531a73f 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<PutSmb>::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<SmbConnectionControllerService> smb_connection_controller_service_; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<PutSmb>::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::extensions::smb diff --git a/extensions/splunk/PutSplunkHTTP.h b/extensions/splunk/PutSplunkHTTP.h index 8fbda961c..831201aeb 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<PutSplunkHTTP>::getLogger(uuid_); } PutSplunkHTTP(const PutSplunkHTTP&) = delete; PutSplunkHTTP(PutSplunkHTTP&&) = delete; @@ -114,7 +115,6 @@ class PutSplunkHTTP final : public SplunkHECProcessor { std::optional<std::string> source_; std::optional<std::string> host_; std::optional<std::string> index_; - std::shared_ptr<core::logging::Logger> logger_{core::logging::LoggerFactory<PutSplunkHTTP>::getLogger(uuid_)}; std::shared_ptr<utils::ResourceQueue<http::HTTPClient>> client_queue_; }; diff --git a/extensions/standard-processors/modbus/FetchModbusTcp.h b/extensions/standard-processors/modbus/FetchModbusTcp.h index 0fe2fd172..99c0ce6ae 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<FetchModbusTcp>::getLogger(uuid_); } EXTENSIONAPI static constexpr auto Description = "Processor able to read data from industrial PLCs using Modbus TCP/IP"; @@ -136,7 +137,6 @@ class FetchModbusTcp final : public core::ProcessorImpl { std::optional<size_t> max_size_of_socket_send_buffer_; std::chrono::milliseconds timeout_duration_ = std::chrono::seconds(15); std::optional<asio::ssl::context> ssl_context_; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<FetchModbusTcp>::getLogger(uuid_); std::shared_ptr<core::RecordSetWriter> 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 69ea5c341..55bd7fc4e 100644 --- a/extensions/standard-processors/processors/AppendHostInfo.h +++ b/extensions/standard-processors/processors/AppendHostInfo.h @@ -42,8 +42,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<AppendHostInfo>::getLogger(uuid_); } ~AppendHostInfo() override = default; @@ -94,7 +95,6 @@ class AppendHostInfo : public core::ProcessorImpl { private: std::shared_mutex shared_mutex_; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<AppendHostInfo>::getLogger(uuid_); std::string hostname_attribute_name_; std::string ipaddress_attribute_name_; std::optional<std::regex> interface_name_filter_; diff --git a/extensions/standard-processors/processors/AttributeRollingWindow.h b/extensions/standard-processors/processors/AttributeRollingWindow.h index 01e9c3b63..4f89cb665 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<AttributeRol std::optional<std::chrono::milliseconds> time_window_{}; std::optional<size_t> window_length_{}; std::string attribute_name_prefix_; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<AttributeRollingWindow>::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 b0a2bc968..2e0c421ec 100644 --- a/extensions/standard-processors/processors/AttributesToJSON.h +++ b/extensions/standard-processors/processors/AttributesToJSON.h @@ -118,8 +118,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<AttributesToJSON>::getLogger(uuid_); } void initialize() override; @@ -132,7 +133,6 @@ class AttributesToJSON : public core::ProcessorImpl { void addAttributeToJson(rapidjson::Document& document, const std::string& key, const std::optional<std::string>& value) const; std::string buildAttributeJsonData(const core::FlowFile::AttributeMap& flowfile_attributes); - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<AttributesToJSON>::getLogger(uuid_); std::vector<std::string> attribute_list_; std::optional<utils::Regex> 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 1b62fc7ce..0b49962d1 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<DefragmentText>::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "DefragmentText splits and merges incoming flowfiles so cohesive messages are not split between them. " @@ -157,7 +158,6 @@ class DefragmentText : public core::ProcessorImpl { std::optional<std::chrono::milliseconds> max_age_; std::optional<size_t> max_size_; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<DefragmentText>::getLogger(uuid_); core::FlowFileStore flow_file_store_; std::unordered_map<FragmentSource::Id, FragmentSource, FragmentSource::Id::hash> fragment_sources_; diff --git a/extensions/standard-processors/processors/ExtractText.h b/extensions/standard-processors/processors/ExtractText.h index 975928578..71ee5fbfb 100644 --- a/extensions/standard-processors/processors/ExtractText.h +++ b/extensions/standard-processors/processors/ExtractText.h @@ -38,8 +38,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<ExtractText>::getLogger(uuid_); } // Default maximum bytes to read into an attribute @@ -118,9 +119,6 @@ class ExtractText : public core::ProcessorImpl { gsl::not_null<core::ProcessContext*> ctx_; std::shared_ptr<core::logging::Logger> logger_; }; - - private: - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<ExtractText>::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 8c7081348..896ad30e5 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<FetchFile>::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. " @@ -177,7 +178,6 @@ class FetchFile final : public core::ProcessorImpl { utils::LogUtils::LogLevelOption log_level_when_file_not_found_{}; utils::LogUtils::LogLevelOption log_level_when_permission_denied_{}; size_t buffer_size_{}; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<FetchFile>::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 fe0a5db65..2e173750c 100644 --- a/extensions/standard-processors/processors/GenerateFlowFile.h +++ b/extensions/standard-processors/processors/GenerateFlowFile.h @@ -41,6 +41,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<GenerateFlowFile>::getLogger(uuid_); } ~GenerateFlowFile() override = default; @@ -124,8 +125,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<core::logging::Logger> logger_ = core::logging::LoggerFactory<GenerateFlowFile>::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 4ed09360b..5aa32033a 100644 --- a/extensions/standard-processors/processors/GetFile.h +++ b/extensions/standard-processors/processors/GetFile.h @@ -84,9 +84,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<GetFileMetrics>(*this)); + logger_ = core::logging::LoggerFactory<GetFile>::getLogger(uuid_); } ~GetFile() override = default; @@ -196,7 +197,6 @@ class GetFile : public core::ProcessorImpl { mutable std::mutex directory_listing_mutex_; std::atomic<std::chrono::time_point<std::chrono::system_clock>> last_listing_time_{}; size_t buffer_size_{}; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<GetFile>::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 471985809..4313fabed 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<GetTCP>::getLogger(uuid_); } ~GetTCP() override { @@ -185,7 +186,6 @@ class GetTCP : public core::ProcessorImpl { std::optional<TcpClient> client_; size_t max_batch_size_{500}; std::thread client_thread_; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<GetTCP>::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 7e332bc1d..3d4507d84 100644 --- a/extensions/standard-processors/processors/HashContent.h +++ b/extensions/standard-processors/processors/HashContent.h @@ -141,8 +141,9 @@ static const std::map<std::string, const std::function<HashReturnType(const std: class HashContent : public core::ProcessorImpl { public: - explicit HashContent(std::string_view name, const utils::Identifier& uuid = {}) + explicit HashContent(const std::string_view name, const utils::Identifier& uuid = {}) : ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory<HashContent>::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "HashContent calculates the checksum of the content of the flowfile and adds it as an attribute. " @@ -185,7 +186,6 @@ class HashContent : public core::ProcessorImpl { void initialize() override; private: - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<HashContent>::getLogger(uuid_); std::function<HashReturnType(const std::shared_ptr<io::InputStream>&)> algorithm_ = SHA256Hash; std::string attrKey_; bool failOnEmpty_{}; diff --git a/extensions/standard-processors/processors/InvokeHTTP.h b/extensions/standard-processors/processors/InvokeHTTP.h index b195603fb..feaadef65 100644 --- a/extensions/standard-processors/processors/InvokeHTTP.h +++ b/extensions/standard-processors/processors/InvokeHTTP.h @@ -127,8 +127,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<InvokeHTTP>::getLogger(uuid_); setTriggerWhenEmpty(true); } @@ -366,12 +367,7 @@ class InvokeHTTP : public core::ProcessorImpl { http::HTTPProxy proxy_{}; bool follow_redirects_ = false; std::optional<std::string> content_type_; - - invoke_http::InvalidHTTPHeaderFieldHandlingOption invalid_http_header_field_handling_strategy_{}; - - std::shared_ptr<core::logging::Logger> logger_{core::logging::LoggerFactory<InvokeHTTP>::getLogger(uuid_)}; - std::unique_ptr<invoke_http::HttpClientStore> client_queue_; }; diff --git a/extensions/standard-processors/processors/JoltTransformJSON.h b/extensions/standard-processors/processors/JoltTransformJSON.h index 83b48412f..071f264ca 100644 --- a/extensions/standard-processors/processors/JoltTransformJSON.h +++ b/extensions/standard-processors/processors/JoltTransformJSON.h @@ -38,8 +38,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<JoltTransformJSON>::getLogger(uuid_); + } EXTENSIONAPI static constexpr const char* Description = "Applies a list of Jolt specifications to the flowfile JSON payload. A new FlowFile is created " @@ -85,7 +87,6 @@ class JoltTransformJSON : public core::ProcessorImpl { private: jolt_transform_json::JoltTransform transform_; std::optional<utils::jolt::Spec> spec_; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<JoltTransformJSON>::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 780f23877..e18d660ca 100644 --- a/extensions/standard-processors/processors/ListFile.h +++ b/extensions/standard-processors/processors/ListFile.h @@ -39,8 +39,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<ListFile>::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "Retrieves a listing of files from the local filesystem. For each file that is listed, " @@ -149,7 +150,6 @@ class ListFile : public core::ProcessorImpl { private: std::shared_ptr<core::FlowFile> createFlowFile(core::ProcessSession& session, const utils::ListedFile& listed_file); - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<ListFile>::getLogger(uuid_); std::filesystem::path input_directory_; std::unique_ptr<minifi::utils::ListingStateManager> state_manager_; bool recurse_subdirectories_ = true; diff --git a/extensions/standard-processors/processors/LogAttribute.h b/extensions/standard-processors/processors/LogAttribute.h index 20c7a60be..96b3a5fba 100644 --- a/extensions/standard-processors/processors/LogAttribute.h +++ b/extensions/standard-processors/processors/LogAttribute.h @@ -41,6 +41,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<LogAttribute>::getLogger(uuid_); logger_->set_max_log_size(-1); } ~LogAttribute() override = default; @@ -115,7 +116,6 @@ class LogAttribute : public core::ProcessorImpl { uint64_t flowfiles_to_log_{1}; bool hexencode_{false}; uint64_t max_line_length_{80}; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<LogAttribute>::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 6bbeb7d07..8b5f35523 100644 --- a/extensions/standard-processors/processors/PutFile.h +++ b/extensions/standard-processors/processors/PutFile.h @@ -37,8 +37,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<PutFile>::getLogger(uuid_); } ~PutFile() override = default; @@ -121,7 +122,6 @@ class PutFile : public core::ProcessorImpl { bool directoryIsFull(const std::filesystem::path& directory) const; std::optional<std::filesystem::path> getDestinationPath(core::ProcessContext& context, const std::shared_ptr<core::FlowFile>& flow_file); void putFile(core::ProcessSession& session, const std::shared_ptr<core::FlowFile>& flow_file, const std::filesystem::path& dest_file); - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<PutFile>::getLogger(uuid_); static std::shared_ptr<utils::IdGenerator> id_generator_; #ifndef WIN32 diff --git a/extensions/standard-processors/processors/PutTCP.cpp b/extensions/standard-processors/processors/PutTCP.cpp index 404965043..b7290d1f6 100644 --- a/extensions/standard-processors/processors/PutTCP.cpp +++ b/extensions/standard-processors/processors/PutTCP.cpp @@ -38,8 +38,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<PutTCP>::getLogger(uuid_); +} PutTCP::~PutTCP() = default; diff --git a/extensions/standard-processors/processors/PutTCP.h b/extensions/standard-processors/processors/PutTCP.h index ed11318f6..0d8b7abfe 100644 --- a/extensions/standard-processors/processors/PutTCP.h +++ b/extensions/standard-processors/processors/PutTCP.h @@ -127,7 +127,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; @@ -159,7 +159,6 @@ class PutTCP final : public core::ProcessorImpl { std::optional<size_t> max_size_of_socket_send_buffer_; std::chrono::milliseconds timeout_duration_ = std::chrono::seconds(15); std::optional<asio::ssl::context> ssl_context_; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<PutTCP>::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 173b7d315..abdb88d6b 100644 --- a/extensions/standard-processors/processors/RetryFlowFile.h +++ b/extensions/standard-processors/processors/RetryFlowFile.h @@ -42,8 +42,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<RetryFlowFile>::getLogger(uuid_); + } ~RetryFlowFile() override = default; // ReuseMode allowed values @@ -157,8 +159,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<core::Property> exceeded_flowfile_attribute_keys_; - - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<RetryFlowFile>::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 dd3e1fa6a..30fe8ee6c 100644 --- a/extensions/standard-processors/processors/RouteOnAttribute.h +++ b/extensions/standard-processors/processors/RouteOnAttribute.h @@ -35,8 +35,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<RouteOnAttribute>::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "Routes FlowFiles based on their Attributes using the Attribute Expression Language.\n\n" @@ -62,7 +63,6 @@ class RouteOnAttribute : public core::ProcessorImpl { void initialize() override; private: - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<RouteOnAttribute>::getLogger(uuid_); std::map<std::string, std::string> route_properties_; std::map<std::string, core::Relationship> route_rels_; }; diff --git a/extensions/standard-processors/processors/SegmentContent.h b/extensions/standard-processors/processors/SegmentContent.h index b7c0e8027..6e4962ad6 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<SegmentContent>::getLogger(uuid_); + } EXTENSIONAPI static constexpr auto Description = "Segments a FlowFile into multiple smaller segments on byte boundaries."; @@ -74,7 +76,6 @@ class SegmentContent final : public core::ProcessorImpl { private: size_t buffer_size_{}; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<SegmentContent>::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 ff626c626..a07921220 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<SplitContent>::getLogger(uuid_); + } using size_type = std::vector<std::byte>::size_type; enum class ByteSequenceFormat { Hexadecimal, Text }; @@ -123,7 +125,6 @@ class SplitContent final : public core::ProcessorImpl { bool keep_byte_sequence = false; ByteSequenceLocation byte_sequence_location_ = ByteSequenceLocation::Trailing; size_t buffer_size_{}; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<SplitContent>::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 27bdd7c93..510a8f44c 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<SplitRecord> { std::shared_ptr<core::RecordSetReader> record_set_reader_; std::shared_ptr<core::RecordSetWriter> record_set_writer_; - - std::shared_ptr<core::logging::Logger> logger_{core::logging::LoggerFactory<SplitRecord>::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 2bb37f20c..b461aad9b 100644 --- a/extensions/standard-processors/processors/SplitText.h +++ b/extensions/standard-processors/processors/SplitText.h @@ -87,8 +87,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<SplitText>::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_; size_t buffer_size_{}; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<SplitText>::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 d70b024d1..700a40a65 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<TailFile>::getLogger(uuid_); } ~TailFile() override = default; @@ -284,7 +285,6 @@ class TailFile : public core::ProcessorImpl { std::unordered_map<std::string, controllers::AttributeProviderService::AttributeMap> extra_attributes_; std::optional<uint32_t> batch_size_; size_t buffer_size_{}; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<TailFile>::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 d6ec5e766..2cd1ba2d0 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<UpdateAttribute>::getLogger(uuid_); } EXTENSIONAPI static constexpr const char* Description = "This processor updates the attributes of a FlowFile using properties that are added by the user. " @@ -57,9 +58,6 @@ class UpdateAttribute : public core::ProcessorImpl { void onTrigger(core::ProcessContext& context, core::ProcessSession& session) override; void initialize() override; - - private: - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<UpdateAttribute>::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/standard-processors/tests/unit/ProcessorTests.cpp b/extensions/standard-processors/tests/unit/ProcessorTests.cpp index dbcdee6db..c2d23bfc6 100644 --- a/extensions/standard-processors/tests/unit/ProcessorTests.cpp +++ b/extensions/standard-processors/tests/unit/ProcessorTests.cpp @@ -50,6 +50,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; @@ -788,6 +789,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<minifi::core::Processor>(); + LogTestController::getInstance().setDebug<minifi::processors::TailFile>(); std::shared_ptr<TestPlan> plan = testController.createPlan(); auto processor = plan->addProcessor("TailFile", "myProc"); diff --git a/extensions/systemd/ConsumeJournald.cpp b/extensions/systemd/ConsumeJournald.cpp index 7be9c8af0..fa212bad7 100644 --- a/extensions/systemd/ConsumeJournald.cpp +++ b/extensions/systemd/ConsumeJournald.cpp @@ -34,8 +34,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::LibWrapper>&& libwrapper) - :core::ProcessorImpl{name, id}, libwrapper_{std::move(libwrapper)} -{} + : core::ProcessorImpl{name, id}, libwrapper_{std::move(libwrapper)} { + logger_ = core::logging::LoggerFactory<ConsumeJournald>::getLogger(uuid_); +} void ConsumeJournald::initialize() { setSupportedProperties(Properties); @@ -95,6 +96,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 7ef4181c4..8557adb16 100644 --- a/extensions/systemd/ConsumeJournald.h +++ b/extensions/systemd/ConsumeJournald.h @@ -145,7 +145,6 @@ class ConsumeJournald final : public core::ProcessorImpl { std::string getCursor() const; std::atomic<bool> running_{false}; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<ConsumeJournald>::getLogger(uuid_); core::StateManager* state_manager_ = nullptr; std::unique_ptr<libwrapper::LibWrapper> libwrapper_; std::unique_ptr<utils::FifoExecutor> worker_; diff --git a/extensions/test-processors/KamikazeProcessor.h b/extensions/test-processors/KamikazeProcessor.h index 155e0bf20..996766bff 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<KamikazeProcessor>::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<core::logging::Logger> logger_ = core::logging::LoggerFactory<KamikazeProcessor>::getLogger(uuid_); }; } // namespace org::apache::nifi::minifi::processors diff --git a/extensions/test-processors/LogOnDestructionProcessor.h b/extensions/test-processors/LogOnDestructionProcessor.h index 0d03c2c25..2f808d815 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<LogOnDestructionProcessor>::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<core::logging::Logger> logger_ = core::logging::LoggerFactory<LogOnDestructionProcessor>::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 948186c79..ec9ed90fa 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<ConsumeWindowsEventLog>::getLogger(uuid_)) { +ConsumeWindowsEventLog::ConsumeWindowsEventLog(const std::string_view name, const utils::Identifier& uuid) + : core::ProcessorImpl(name, uuid) { + logger_ = core::logging::LoggerFactory<ConsumeWindowsEventLog>::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 fb0e3d832..ecb395698 100644 --- a/extensions/windows-event-log/ConsumeWindowsEventLog.h +++ b/extensions/windows-event-log/ConsumeWindowsEventLog.h @@ -80,7 +80,7 @@ class Bookmark; class ConsumeWindowsEventLog : public core::ProcessorImpl { public: - explicit ConsumeWindowsEventLog(const std::string& name, const utils::Identifier& uuid = {}); + explicit ConsumeWindowsEventLog(const std::string_view name, const utils::Identifier& uuid = {}); ~ConsumeWindowsEventLog() override; @@ -237,7 +237,6 @@ class ConsumeWindowsEventLog : public core::ProcessorImpl { void addMatchedFieldsAsAttributes(const cwel::EventRender &eventRender, core::ProcessSession &session, const std::shared_ptr<core::FlowFile> &flowFile) const; - std::shared_ptr<core::logging::Logger> logger_; core::StateManager* state_manager_{nullptr}; wel::METADATA_NAMES header_names_; std::optional<std::string> header_delimiter_; diff --git a/libminifi/test/libtest/unit/ReadFromFlowFileTestProcessor.h b/libminifi/test/libtest/unit/ReadFromFlowFileTestProcessor.h index 869c48bb4..a1fdd7f28 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<ReadFromFlowFileTestProcessor>::getLogger(uuid_); } static constexpr const char* Description = "ReadFromFlowFileTestProcessor (only for testing purposes)"; @@ -90,7 +91,6 @@ class ReadFromFlowFileTestProcessor : public core::ProcessorImpl { std::map<std::string, std::string> attributes_; }; bool clear_on_trigger_ = true; - std::shared_ptr<core::logging::Logger> logger_ = core::logging::LoggerFactory<ReadFromFlowFileTestProcessor>::getLogger(uuid_); std::vector<FlowFileData> flow_files_read_; }; diff --git a/libminifi/test/libtest/unit/WriteToFlowFileTestProcessor.h b/libminifi/test/libtest/unit/WriteToFlowFileTestProcessor.h index 3949be180..6f0b13ba9 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<WriteToFlowFileTestProcessor>::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<core::logging::Logger> logger_ = core::logging::LoggerFactory<WriteToFlowFileTestProcessor>::getLogger(uuid_); std::string content_; };
