Merge in SNORT/snort3 from ~ASERBENI/snort3:log_perf_ci to master
Squashed commit of the following:
commit
11c5aa69552e778d782dc74bce964d8e2e34378e
Author: Andrii Serbeniuk <aserbeni@cisco.com>
Date: Fri Sep 6 10:13:34 2024 +0300
extractor: rewrite std writer to use text_log utility
This way its output will be written to the same descriptor as ips events. In most of the cases it's stdout, but it can also be descriptor 3 if snort was build with --enable-stdlog
}
}
+StdExtractorWriter::StdExtractorWriter() : ExtractorWriter(), extr_std_log(snort::TextLog_Init("stdout"))
+{}
+
+StdExtractorWriter::~StdExtractorWriter()
+{
+ snort::TextLog_Term(extr_std_log);
+}
+
+void StdExtractorWriter::write(const char* ss)
+{
+ snort::TextLog_Print(extr_std_log, "%s", ss);
+}
+
#ifdef UNIT_TEST
#include "catch/snort_catch.h"
#include <mutex>
#include <string>
+#include "log/text_log.h"
+
class OutputType
{
public:
class StdExtractorWriter : public ExtractorWriter
{
public:
- StdExtractorWriter() = default;
+ StdExtractorWriter();
+ ~StdExtractorWriter() override;
- void write(const char* ss) override
- { fprintf(stdout, "%s", ss); }
+ void write(const char* ss) override;
void lock() override
{ write_mutex.lock(); }
private:
std::mutex write_mutex;
+ TextLog* extr_std_log;
};
#endif