mirror of
https://github.com/openappsec/openappsec.git
synced 2025-11-19 02:30:36 +03:00
sync code
This commit is contained in:
@@ -37,6 +37,7 @@ FogStream::sendLog(const Report &log)
|
||||
ScopedContext ctx;
|
||||
ctx.registerValue<bool>("Obfuscate log field", true);
|
||||
|
||||
dbgTrace(D_REPORT) << "Sending log to fog";
|
||||
LogRest rest(log);
|
||||
i_msg->sendAsyncMessage(HTTPMethod::POST, fog_log_uri, rest, MessageCategory::LOG);
|
||||
}
|
||||
|
||||
@@ -14,15 +14,23 @@
|
||||
#include "log_generator.h"
|
||||
|
||||
using namespace std;
|
||||
USE_DEBUG_FLAG(D_LOGGING);
|
||||
|
||||
extern const string unnamed_service;
|
||||
|
||||
LogGen::~LogGen()
|
||||
{
|
||||
try {
|
||||
if (send_log) Singleton::Consume<I_Logging>::by<LogGen>()->sendLog(log);
|
||||
if (send_log) {
|
||||
dbgTrace(D_LOGGING) << "sending log";
|
||||
Singleton::Consume<I_Logging>::by<LogGen>()->sendLog(log);
|
||||
} else {
|
||||
dbgTrace(D_LOGGING) << "not sending log";
|
||||
}
|
||||
} catch (...) {
|
||||
dbgWarning(D_LOGGING) << "Failed to send log";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LogGen &
|
||||
|
||||
@@ -157,7 +157,7 @@ protected:
|
||||
|
||||
private:
|
||||
void init();
|
||||
void sendLog(const std::vector<char> &data);
|
||||
void sendLogData(const std::vector<char> &data);
|
||||
I_MainLoop::RoutineID log_send_routine = -1;
|
||||
};
|
||||
|
||||
|
||||
@@ -162,11 +162,17 @@ public:
|
||||
sendLog(const Report &log) override
|
||||
{
|
||||
if (getConf("agent.config.log.useBulkMode", "Enable bulk of logs", true)) {
|
||||
dbgTrace(D_REPORT) << "Adding log to bulk";
|
||||
reports.setBulkSize(getConfigurationWithDefault<uint>(100, "Logging", "Sent log bulk size"));
|
||||
reports.push(log);
|
||||
if (reports.sizeQueue() >= 4) {
|
||||
auto persistence_only = getConf("agent.config.log.skip.enable", "Enable Log skipping", true);
|
||||
sendBufferedLogsImpl(false, persistence_only);
|
||||
dbgTrace(D_REPORT)
|
||||
<< "Sending buffered logs from queue size: "
|
||||
<< reports.sizeQueue()
|
||||
<< ", persistence_only: "
|
||||
<< persistence_only;
|
||||
sendBufferedLogsImpl(false, persistence_only);
|
||||
}
|
||||
} else {
|
||||
LogEventLogsSent(true).notify();
|
||||
@@ -230,10 +236,22 @@ private:
|
||||
for (auto &iter : local_streams) {
|
||||
LogBulkRest sub_batch;
|
||||
for (const auto &log : batch) {
|
||||
if (log.isStreamActive(iter.first)) sub_batch.push(log);
|
||||
if (log.isStreamActive(iter.first)) {
|
||||
dbgTrace(D_REPORT)
|
||||
<< "stream: "
|
||||
<< (int) iter.first
|
||||
<< " is active. adding log to sub-batch";
|
||||
sub_batch.push(log);
|
||||
}
|
||||
}
|
||||
|
||||
if (sub_batch.size()) {
|
||||
dbgTrace(D_REPORT)
|
||||
<< "Sending log to stream: "
|
||||
<< (int) iter.first
|
||||
<< ", batch size: "
|
||||
<< sub_batch.size();
|
||||
|
||||
iter.second->sendLog(sub_batch, persistence_only);
|
||||
if (is_async) i_mainloop->yield();
|
||||
}
|
||||
|
||||
@@ -55,13 +55,13 @@ SyslogStream::sendLog(const Report &log)
|
||||
vector<char> data(syslog_report.begin(), syslog_report.end());
|
||||
log_send_routine = mainloop->addOneTimeRoutine(
|
||||
I_MainLoop::RoutineType::Offline,
|
||||
[this, data] () { sendLog(data); },
|
||||
[this, data] () { sendLogData(data); },
|
||||
"Logging Syslog stream messaging"
|
||||
);
|
||||
}
|
||||
|
||||
void
|
||||
SyslogStream::sendLog(const vector<char> &data)
|
||||
SyslogStream::sendLogData(const vector<char> &data)
|
||||
{
|
||||
dbgTrace(D_REPORT) << "Sending Syslog log." << " Max logs per send: " << max_logs_per_send;
|
||||
sendLogWithQueue(data);
|
||||
|
||||
Reference in New Issue
Block a user