Skip to content

Commit

Permalink
feat: documentation comments and rebase corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
LucioDonda committed Jan 13, 2025
1 parent 92ab377 commit 71eeba5
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 34 deletions.
9 changes: 3 additions & 6 deletions src/modules/logcollector/include/logcollector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ class Logcollector {

/// @brief Clean all readers
void CleanAllReaders();
#ifdef _WIN32
/// @brief Sets up the Windows Event Channel reader
/// @param configurationParser Configuration parser
void SetupWEReader(const std::shared_ptr<const configuration::ConfigurationParser> configurationParser);
#endif

private:
/// @brief Module name
Expand Down Expand Up @@ -116,7 +111,9 @@ class Logcollector {
std::list<boost::asio::steady_timer*> m_timers;
};

//TODO:check
/// @brief Add platform specific implementation of IReader to logcollector.
/// @param ConfgurationParser where to get parameters.
/// @param logcollector instance.
void AddPlatformSpecificReader(std::shared_ptr<const configuration::ConfigurationParser> configurationParser, Logcollector &logcollector);

}
1 change: 1 addition & 0 deletions src/modules/logcollector/src/another_reader_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace logcollector {

//TODO: Delete once the unix implementation is ready
void AddPlatformSpecificReader([[maybe_unused]] std::shared_ptr<const configuration::ConfigurationParser> configurationParser, [[maybe_unused]] Logcollector &logcollector)
{

Expand Down
8 changes: 4 additions & 4 deletions src/modules/logcollector/src/event_reader_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Awaitable WindowsEventTracerReader::QueryEvents()
switch (action)
{
case EvtSubscribeActionDeliver:
reader->ProcessEvent(event, reader->GetChannel());
reader->ProcessEvent(event);
break;

case EvtSubscribeActionError:
Expand All @@ -79,7 +79,7 @@ Awaitable WindowsEventTracerReader::QueryEvents()
NULL,
this,
subscriptionCallback,
EvtSubscribeToFutureEvents); // EvtSubscribeStartAtOldestRecord
EvtSubscribeToFutureEvents);

if (!subscriptionHandle)
{
Expand All @@ -101,7 +101,7 @@ Awaitable WindowsEventTracerReader::QueryEvents()
}
}

void WindowsEventTracerReader::ProcessEvent(EVT_HANDLE event, const std::string channel)
void WindowsEventTracerReader::ProcessEvent(EVT_HANDLE event)
{
DWORD bufferUsed = 0;
DWORD propertyCount = 0;
Expand All @@ -123,7 +123,7 @@ void WindowsEventTracerReader::ProcessEvent(EVT_HANDLE event, const std::string
LogError("Cannot convert utf16 string: {}", e.what());
return;
}
m_logcollector.SendMessage(channel, logString, m_collectorType);
m_logcollector.SendMessage(m_channel, logString, m_collectorType);
}
}
}
Expand Down
37 changes: 18 additions & 19 deletions src/modules/logcollector/src/event_reader_win.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,50 +20,49 @@
namespace logcollector {

/// @brief Windows Event Tracer Reader class
/// TODO: doc
class WindowsEventTracerReader : public IReader
{
public:
/// @brief Constructor for the Windows Event Tracer Reader
/// @param logcollector Log collector instance
/// @param channels List of channel names
/// @param queries List of queries
/// @param reloadInterval
/// @param logcollector Log collector instance.
/// @param channel Channel name.
/// @param query Query.
/// @param channelRefreshInterval channel query refresh interval in millisecconds.
WindowsEventTracerReader(Logcollector &logcollector,
const std::string channel,
const std::string query,
const std::time_t channelRefreshInterval);

/// @brief Runs the file reader
/// @return Awaitable result
/// @brief Runs the event reader.
/// @return Awaitable result.
Awaitable Run() override;

//TODO: doc
//@brief Stops the event reader.
void Stop() override;

// Main function to execute the event query
///@brief Main function to query events from event channel.
Awaitable QueryEvents();

//TODO: doc
std::string GetChannel() { return m_channel; };

private:
// Process an individual event and print its XML representation
void ProcessEvent(EVT_HANDLE event, const std::string channel);
///@brief Process an individual event and print its XML representation.
/// @param event subscription handle event.
void ProcessEvent(EVT_HANDLE event);

//TODO: doc
/// @brief Function for wchar to string convertion.
/// @param buffer wchar vector as input.
/// @return buffer converted to std::string.
std::string WcharVecToString(std::vector<wchar_t>& buffer);

/// @brief
/// @brief channel name.
std::string m_channel;

/// @brief
/// @brief query string.
std::string m_query;

/// @brief
/// @brief channel query refresh interval in millisecconds.
std::time_t m_ChannelsRefreshInterval;

/// @brief collector type
/// @brief collector type.
const std::string m_collectorType = "eventchannel";
};
} // namespace logcollector
3 changes: 1 addition & 2 deletions src/modules/logcollector/src/logcollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ void Logcollector::SendMessage(const std::string& location, const std::string& l
auto message = Message(MessageType::STATELESS, data, m_moduleName, collectorType, metadata.dump());
m_pushMessage(message);

//TODO: undo
LogInfo("Message pushed: '{}':'{}'", location, log);
LogTrace("Message pushed: '{}':'{}'", location, log);
}

void Logcollector::AddReader(std::shared_ptr<IReader> reader)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ TEST_F(WindowsEventChannel, RunMethodEnqueueTask)
{
auto mockedLogcollector = LogcollectorMock();
auto reader = std::make_shared<WindowsEventTracerReader>(mockedLogcollector, channelName, query, 5000);
EXPECT_EQ(reader->GetChannel(), channelName);

EXPECT_CALL(mockedLogcollector, EnqueueTask(::testing::_)).Times(1);
EXPECT_CALL(mockedLogcollector, AddReader(::testing::_));
Expand Down
4 changes: 2 additions & 2 deletions src/modules/logcollector/tests/unit/file_reader_win_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ using namespace logcollector;

static constexpr auto TMP_FILE_DIR = "C:\\Temp\\";

inline std::string GetFullFileName(const std::string& filename) {
//TODO: move to setup stage of test only for windows
inline std::string GetFullFileName(const std::string& filename)
{
std::filesystem::create_directories(TMP_FILE_DIR);
return TMP_FILE_DIR + filename;
}
Expand Down

0 comments on commit 71eeba5

Please sign in to comment.