Skip to content

Commit

Permalink
[wpiutil] Fix FileLogger only logging one byte at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold856 committed Oct 3, 2024
1 parent f82e1c9 commit 893e63a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions wpiutil/src/main/native/cpp/FileLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ FileLogger::FileLogger(std::string_view file,
m_inotifyWatchHandle{
inotify_add_watch(m_inotifyHandle, file.data(), IN_MODIFY)},
m_thread{[=, this] {
char buf[4000];
char buf[2000];
struct inotify_event ev;
int len = 0;
lseek(m_fileHandle, 0, SEEK_END);
while ((len = read(m_inotifyHandle, &ev, sizeof(ev))) > 0) {
int bufLen = 0;
if ((bufLen = read(m_fileHandle, buf, sizeof(buf)) > 0)) {
int eventSize = sizeof(ev) + NAME_MAX + 1;
while (read(m_inotifyHandle, &ev, eventSize) > 0) {
int bufLen = read(m_fileHandle, buf, sizeof(buf));
if (bufLen > 0) {
callback(std::string_view{buf, static_cast<size_t>(bufLen)});
}
}
Expand Down

0 comments on commit 893e63a

Please sign in to comment.