Adds AuditLogWriter{Serial,Parallel} classes

Furhter those classes will be used to persist (or send) the auditlogs.
This commit is contained in:
Felipe Zimmerle
2015-07-08 18:16:03 -03:00
parent e44d6e280d
commit 885fe14f30
9 changed files with 249 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
/**
/*
* ModSecurity, http://www.modsecurity.org/
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
*
@@ -24,6 +24,8 @@
#include <fstream>
#include <regex>
#include "src/audit_log_writer_parallel.h"
#include "src/audit_log_writer_serial.h"
#define PARTS_CONSTAINS(a, c) \
if (new_parts.find(toupper(a)) != std::string::npos \
@@ -101,7 +103,29 @@ bool AuditLog::setType(AuditLogType audit_type) {
bool AuditLog::init() {
return true;
if (m_type == ParallelAuditLogType) {
m_writer = new AuditLogWriterParallel();
}
if (m_type == SerialAuditLogType) {
m_writer = new AuditLogWriterSerial();
}
if (m_writer == NULL || m_writer->init() == false) {
std::cout << "not able to open the log for write." << std::endl;
return false;
}
/* Sanity check */
if (m_status == RelevantOnlyAuditLogStatus) {
if (m_relevant.empty()) {
std::cout << "m_relevant cannot be null while status is " << \
"RelevantOnly" << std::endl;
return false;
}
}
return true;
}