blob: e7059d16aaeea6ebad2f316df4f17ba7c14ce397 [file] [log] [blame]
Brian Silvermanf5f8d8e2015-12-06 18:39:12 -05001#ifndef AOS_TESTING_TEST_LOGGING_H_
2#define AOS_TESTING_TEST_LOGGING_H_
3
Austin Schuh82c0c822019-05-27 19:55:20 -07004#include "aos/time/time.h"
5
Brian Silvermanf5f8d8e2015-12-06 18:39:12 -05006namespace aos {
7namespace testing {
8
9// Enables the logging framework for use during a gtest test.
10// It will print out all WARNING and above messages all of the time. It will
11// also print out all log messages when a test fails.
12// This function only needs to be called once in each process (after gtest is
13// initialized), however it can be called more than that.
14void EnableTestLogging();
15
16// Redirect the messages enabled by EnableTestLogging() function to a file.
17// By default the messages are printed to standard output.
18void SetLogFileName(const char* filename);
19
20// Force the messages to be printed as they are handled by the logging
21// framework. This can be useful for tests that hang where no messages would
22// otherwise be printed. This is also useful for tests that do pass, but where
23// we want to use graphing tools to verify what's happening.
24void ForcePrintLogsDuringTests();
25
Austin Schuh82c0c822019-05-27 19:55:20 -070026// Sets the current mock logging time to monotonic_now. This only applies to
27// the current thread.
28void MockTime(::aos::monotonic_clock::time_point monotonic_now);
29// Clears the mock logging time for the current thread and goes back to using
30// monotonic_clock::now().
31void UnMockTime();
32
Brian Silvermanf5f8d8e2015-12-06 18:39:12 -050033} // namespace testing
34} // namespace aos
35
36#endif // AOS_TESTING_TEST_LOGGING_H_