Skip to content

Conversation

@belimawr
Copy link
Contributor

What does this PR do?

This PR adds logptest.Logger, a logger meant to be used on tests, its key features:

  • All logs are saved on a single temporary log file
  • No logs are printed during test execution
  • On failures, the log file is kept and its path printed
  • Methods to search and wait for log entries are provided, they keep track of the offset, ensuring ordering when when searching for logs

Why is it important?

It adds a logger to be used in tests with some helper functions

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works

## Author's Checklist
## Related issues

@belimawr belimawr self-assigned this Oct 22, 2025
@belimawr belimawr requested a review from a team as a code owner October 22, 2025 18:55
@belimawr belimawr added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Oct 22, 2025
@belimawr belimawr requested review from faec and mauri870 and removed request for a team October 22, 2025 18:55
This commit adds logptest.Logger, a logger meant to be used on tests,
its key features:
 - All logs are saved on a single temporary log file
 - On failures, the log file is kept and its path printed
 - Methods to search and wait for log entries are provided,
   they keep track of the offset, ensuring ordering when
   when searching for logs
Copy link

@orestisfl orestisfl left a comment

Choose a reason for hiding this comment

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

I would also export both t-based and non-t-based functions for users that do not want to fail their tests for non-matching logs. E.g. we might want to test that logs do NOT contain something

@mauri870
Copy link
Member

I'm currently refactoring the beats receivers test suite and this logger will come in handy, thanks!

@belimawr belimawr requested a review from khushijain21 October 24, 2025 14:01
Co-authored-by: Mauri de Souza Meneguzzo <[email protected]>
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @belimawr

@belimawr belimawr requested a review from mauri870 October 28, 2025 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants