File tree 1 file changed +32
-8
lines changed
1 file changed +32
-8
lines changed Original file line number Diff line number Diff line change 1
1
// /////////////////////////////////////////////////////////////////////
2
2
// File: log.h
3
3
// Description: Include for custom log message for unittest for tesseract.
4
- // based on
5
- // // https://stackoverflow.com/questions/16491675/how-to-send-custom-message-in-google-c-testing-framework
4
+ // based on
5
+ // https://stackoverflow.com/questions/16491675/how-to-send-custom-message-in-google-c-testing-framework
6
6
//
7
7
// Licensed under the Apache License, Version 2.0 (the "License");
8
8
// you may not use this file except in compliance with the License.
14
14
// See the License for the specific language governing permissions and
15
15
// limitations under the License.
16
16
// /////////////////////////////////////////////////////////////////////
17
+
17
18
#ifndef TESSERACT_UNITTEST_LOG_H_
18
19
#define TESSERACT_UNITTEST_LOG_H_
19
20
20
21
#include < iostream>
21
22
22
- static class LOG {
23
- public:
24
- LOG () {}
25
- std::ostream& info () {
26
- std::cout << " [ LOG MSG ] " ;
23
+ enum LogLevel {
24
+ INFO, ERROR
25
+ };
26
+
27
+ static inline std::ostream& LOG (enum LogLevel level)
28
+ {
29
+ switch (level) {
30
+ #if 0
31
+ case DEBUG:
32
+ std::cout << "[DEBUG] ";
33
+ break;
34
+ #endif
35
+ case INFO:
36
+ std::cout << " [INFO] " ;
37
+ break ;
38
+ case ERROR:
39
+ std::cout << " [ERROR] " ;
40
+ break ;
41
+ }
42
+ return std::cout;
43
+ }
44
+
45
+ // https://github.com/google/ion/blob/master/ion/base/logging.h
46
+ static inline std::ostream& QCHECK (bool condition)
47
+ {
48
+ static std::ostream null_stream (nullptr );
49
+ if (condition) {
27
50
return std::cout;
28
51
}
29
- } log;
52
+ return null_stream;
53
+ }
30
54
31
55
#endif // TESSERACT_UNITTEST_LOG_H_
You can’t perform that action at this time.
0 commit comments