Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wpiutil] Refactor FileLogger #7150

Merged
merged 7 commits into from
Oct 8, 2024
Merged

Conversation

Gold856
Copy link
Contributor

@Gold856 Gold856 commented Oct 3, 2024

FileLogger now logs entire flushed blocks of data, instead of breaking it up into lines.

Fixes #7135.

@Gold856 Gold856 force-pushed the fix-filelogger branch 2 times, most recently from 893e63a to d64ecc3 Compare October 3, 2024 02:58
@Gold856 Gold856 marked this pull request as draft October 3, 2024 03:23
@Gold856 Gold856 force-pushed the fix-filelogger branch 3 times, most recently from 5d368ed to de864a9 Compare October 3, 2024 04:23
wpiutil/src/main/native/cpp/FileLogger.cpp Outdated Show resolved Hide resolved
wpiutil/src/main/native/cpp/FileLogger.cpp Outdated Show resolved Hide resolved
wpiutil/src/main/native/cpp/FileLogger.cpp Outdated Show resolved Hide resolved
wpiutil/src/main/native/cpp/FileLogger.cpp Outdated Show resolved Hide resolved
@Gold856 Gold856 marked this pull request as ready for review October 3, 2024 05:36
@Gold856 Gold856 force-pushed the fix-filelogger branch 2 times, most recently from 516ecb3 to d409cb5 Compare October 4, 2024 00:55
@Gold856 Gold856 changed the title [wpiutil] Fix FileLogger only logging one byte at a time [wpiutil] Refactor FileLogger Oct 4, 2024
@Gold856
Copy link
Contributor Author

Gold856 commented Oct 4, 2024

/format

wpiutil/src/main/native/cpp/FileLogger.cpp Outdated Show resolved Hide resolved
wpiutil/src/main/native/cpp/FileLogger.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@KangarooKoala KangarooKoala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to clarify the LineBuffer() doc comment? Here's what it says for reference:

  /**
   * Creates a function that chunks incoming data into lines before calling the
   * callback with the individual line.
   *
   * @param callback The callback that logs lines.
   * @return The function.
   */
  static std::function<void(std::string_view)> LineBuffer(
      std::function<void(std::string_view)> callback);

I think the wording is ambiguous enough that it could be interpreted as either the old behavior or the new behavior, though I'm not sure if that's a reason for or against changing it.

@Gold856
Copy link
Contributor Author

Gold856 commented Oct 5, 2024

/format

Copy link
Contributor

@KangarooKoala KangarooKoala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, looks good! Maybe it's just me, but I'm still iffy about the doc comment wording- "Blocks of whole lines" could be interpreted as "blocks that are split at line endings" or as "blocks that each consist of a whole line". I think it's probably good enough for this PR to be merged- I don't think many people will look at Buffer() anyways, especially since it's C++ (and by extension Python) only- but if anyone has any good ideas then maybe we could discuss those before merging this.

Copy link
Member

@rzblue rzblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good to merge for beta 1

@PeterJohnson PeterJohnson merged commit f150b36 into wpilibsuite:main Oct 8, 2024
34 checks passed
@Gold856 Gold856 deleted the fix-filelogger branch October 8, 2024 22:40
Gold856 added a commit to Gold856/allwpilib that referenced this pull request Oct 10, 2024
Co-authored-by: Ryan Blue <ryanzblue@gmail.com>
Gold856 added a commit to Gold856/allwpilib that referenced this pull request Oct 10, 2024
Co-authored-by: Ryan Blue <ryanzblue@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Console output is garbled in datalogs
4 participants