ADTF  3.18.2
test_logger.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <adtf_utils.h>
10 #include <string>
11 #include <vector>
12 #include <regex>
13 #include <adtfbase/chrono.h>
14 
15 namespace adtf
16 {
17 namespace system
18 {
19 namespace testing
20 {
21 namespace lucky
22 {
23 
28 {
29  public:
30 
34  struct tMessage
35  {
37  uint8_t nLogLevel;
38  std::string strText;
39  std::string strSource;
40  };
41 
45  struct tMessages: public std::vector<tMessage>
46  {
47  public:
52  tMessages Filter(uint8_t nLogLevel);
53 
58  tMessages Filter(const std::string& strContent);
59 
65  tMessages Filter(const std::regex& strPattern, bool bPartialMatch = true);
66 
71  tMessages FilterSource(const std::string& strContent);
72 
78  tMessages FilterSource(const std::regex& strPattern, bool bPartialMatch = true);
79 
84  bool ContainsMessage(const std::string& strContent);
85 
91  bool ContainsMessage(const std::regex& strPattern, bool bPartialMatch = true);
92 
98  tMessage FindMessage(const std::string& strContent);
99 
106  tMessage FindMessage(const std::regex& strPattern, bool bPartialMatch = true);
107  };
108 
114 
119 
125  tMessages GetCurrentMessages(bool bClear = true);
126 
133 
134  private:
135  class cImplementation;
136  std::unique_ptr<cImplementation> m_pImplementation;
137 };
138 
139 }
140 
141 using lucky::cTestLogger;
142 
143 }
144 }
145 }
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Utility class to record all log messages in an ADTF system during tests.
Definition: test_logger.h:28
tMessages GetCurrentMessages(bool bClear=true)
Returns all messages currently received.
bool WaitForMessage(base::flash::tNanoSeconds tmTimeout=base::flash::tNanoSeconds{-1})
This blocks the calling context until either a message was received or the given timeout expired.
Namespace for entire ADTF SDK.
uint8_t nLogLevel
the log level, see adtf::util::log::tLogLevel
Definition: test_logger.h:37
std::string strSource
the source of the message
Definition: test_logger.h:39
Utility class that allows filtering of and searching for messages.
Definition: test_logger.h:46
tMessages Filter(const std::regex &strPattern, bool bPartialMatch=true)
bool ContainsMessage(const std::string &strContent)
tMessage FindMessage(const std::string &strContent)
Find a message that contains the given string.
tMessage FindMessage(const std::regex &strPattern, bool bPartialMatch=true)
Find a message that matches the given pattern.
tMessages FilterSource(const std::string &strContent)
bool ContainsMessage(const std::regex &strPattern, bool bPartialMatch=true)
tMessages Filter(const std::string &strContent)
tMessages FilterSource(const std::regex &strPattern, bool bPartialMatch=true)