diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9c785bddc8..b4779e1557 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -335,6 +335,7 @@ set(bro_SRCS LogMgr.cc LogWriter.cc LogWriterAscii.cc + LogWriterNone.cc Login.cc MIME.cc NCP.cc diff --git a/src/LogMgr.cc b/src/LogMgr.cc index 4fde5d3189..9e320f8810 100644 --- a/src/LogMgr.cc +++ b/src/LogMgr.cc @@ -9,6 +9,7 @@ #include "Net.h" #include "LogWriterAscii.h" +#include "LogWriterNone.h" // Structure describing a log writer type. struct LogWriterDefinition { @@ -20,6 +21,7 @@ struct LogWriterDefinition { // Static table defining all availabel log writers. LogWriterDefinition log_writers[] = { + { BifEnum::Log::WRITER_NONE, "None", 0, LogWriterNone::Instantiate }, { BifEnum::Log::WRITER_ASCII, "Ascii", 0, LogWriterAscii::Instantiate }, // End marker, don't touch. diff --git a/src/LogWriterNone.cc b/src/LogWriterNone.cc new file mode 100644 index 0000000000..592772afdb --- /dev/null +++ b/src/LogWriterNone.cc @@ -0,0 +1,16 @@ + +#include "LogWriterNone.h" + +bool LogWriterNone::DoRotate(string rotated_path, double open, + double close, bool terminating) + { + if ( ! FinishedRotation(string("/dev/null"), Path(), open, close, terminating)) + { + Error(Fmt("error rotating %s", Path().c_str())); + return false; + } + + return true; + } + + diff --git a/src/LogWriterNone.h b/src/LogWriterNone.h new file mode 100644 index 0000000000..3811a19469 --- /dev/null +++ b/src/LogWriterNone.h @@ -0,0 +1,30 @@ +// See the file "COPYING" in the main distribution directory for copyright. +// +// Dummy log writer that just discards everything (but still pretends to rotate). + +#ifndef LOGWRITERNONE_H +#define LOGWRITERNONE_H + +#include "LogWriter.h" + +class LogWriterNone : public LogWriter { +public: + LogWriterNone() {} + ~LogWriterNone() {}; + + static LogWriter* Instantiate() { return new LogWriterNone; } + +protected: + virtual bool DoInit(string path, int num_fields, + const LogField* const * fields) { return true; } + + virtual bool DoWrite(int num_fields, const LogField* const * fields, + LogVal** vals) { return true; } + virtual bool DoSetBuf(bool enabled) { return true; } + virtual bool DoRotate(string rotated_path, double open, double close, + bool terminating); + virtual bool DoFlush() { return true; } + virtual void DoFinish() {} +}; + +#endif diff --git a/src/types.bif b/src/types.bif index 8bc5ab8510..da6bd6e031 100644 --- a/src/types.bif +++ b/src/types.bif @@ -159,6 +159,7 @@ module Log; enum Writer %{ WRITER_DEFAULT, + WRITER_NONE, WRITER_ASCII, %}