Skip to content

Commit

Permalink
Chunk data into lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold856 committed Aug 24, 2024
1 parent d75e3a4 commit 5dacd88
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion wpiutil/src/main/native/include/wpi/FileLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <utility>

#include "wpi/DataLog.h"
#include "wpi/SmallVector.h"
#include "wpi/StringExtras.h"

namespace wpi {
/**
Expand Down Expand Up @@ -46,7 +48,11 @@ class FileLogger {
FileLogger(std::string_view file, log::DataLog& log, std::string_view key)
: FileLogger(file, [entry = log.Start(key, "string"),
&log](std::string_view data) {
log.AppendString(entry, data, 0);
wpi::SmallVector<std::string_view, 16> parts;
wpi::split(data, parts, "\n");
for (auto line : parts) {
log.AppendString(entry, line, 0);
}
}) {}
FileLogger(FileLogger&& other);
FileLogger& operator=(FileLogger&& rhs);
Expand Down

0 comments on commit 5dacd88

Please sign in to comment.