Electroneum
Loading...
Searching...
No Matches
logging.cpp File Reference
#include <boost/filesystem.hpp>
#include "gtest/gtest.h"
#include "file_io_utils.h"
#include "misc_log_ex.h"
Include dependency graph for logging.cpp:

Go to the source code of this file.

Functions

 TEST (logging, no_logs)
 TEST (logging, default)
 TEST (logging, all)
 TEST (logging, glob_suffix)
 TEST (logging, glob_prefix)
 TEST (logging, last_precedence)

Function Documentation

◆ TEST() [1/6]

TEST ( logging ,
all  )

Definition at line 123 of file logging.cpp.

124{
125 init();
126 mlog_set_categories("*:TRACE");
127 log();
128 std::string str;
129 ASSERT_TRUE(load_log_to_string(log_filename, str));
130 ASSERT_TRUE(str.find("global") != std::string::npos);
131 ASSERT_TRUE(str.find("fatal") != std::string::npos);
132 ASSERT_TRUE(str.find("error") != std::string::npos);
133 ASSERT_TRUE(str.find("debug") != std::string::npos);
134 ASSERT_TRUE(str.find("trace") != std::string::npos);
135 cleanup();
136}
#define ASSERT_TRUE(condition)
Definition gtest.h:1865
void mlog_set_categories(const char *categories)
Definition mlog.cpp:238
Here is the call graph for this function:

◆ TEST() [2/6]

TEST ( logging ,
default  )

Definition at line 109 of file logging.cpp.

110{
111 init();
112 log();
113 std::string str;
114 ASSERT_TRUE(load_log_to_string(log_filename, str));
115 ASSERT_TRUE(str.find("global") != std::string::npos);
116 ASSERT_TRUE(str.find("fatal") != std::string::npos);
117 ASSERT_TRUE(str.find("error") != std::string::npos);
118 ASSERT_TRUE(str.find("debug") == std::string::npos);
119 ASSERT_TRUE(str.find("trace") == std::string::npos);
120 cleanup();
121}

◆ TEST() [3/6]

TEST ( logging ,
glob_prefix  )

Definition at line 152 of file logging.cpp.

153{
154 init();
155 mlog_set_categories("*y.z:TRACE");
156 log();
157 std::string str;
158 ASSERT_TRUE(load_log_to_string(log_filename, str));
159 ASSERT_TRUE(str.find("global") == std::string::npos);
160 ASSERT_TRUE(str.find("x.y.z") != std::string::npos);
161 ASSERT_TRUE(str.find("x.y.x") == std::string::npos);
162 ASSERT_TRUE(str.find("y.y.z") != std::string::npos);
163 cleanup();
164}
Here is the call graph for this function:

◆ TEST() [4/6]

TEST ( logging ,
glob_suffix  )

Definition at line 138 of file logging.cpp.

139{
140 init();
141 mlog_set_categories("x.y*:TRACE");
142 log();
143 std::string str;
144 ASSERT_TRUE(load_log_to_string(log_filename, str));
145 ASSERT_TRUE(str.find("global") == std::string::npos);
146 ASSERT_TRUE(str.find("x.y.z") != std::string::npos);
147 ASSERT_TRUE(str.find("x.y.x") != std::string::npos);
148 ASSERT_TRUE(str.find("y.y.z") == std::string::npos);
149 cleanup();
150}
Here is the call graph for this function:

◆ TEST() [5/6]

TEST ( logging ,
last_precedence  )

Definition at line 166 of file logging.cpp.

167{
168 init();
169 mlog_set_categories("gobal:FATAL,glo*:DEBUG");
170 log();
171 std::string str;
172 ASSERT_TRUE(load_log_to_string(log_filename, str));
173 ASSERT_TRUE(nlines(str) == 1);
174 ASSERT_TRUE(str.find("global") != std::string::npos);
175 ASSERT_TRUE(str.find("x.y.z") == std::string::npos);
176 ASSERT_TRUE(str.find("x.y.x") == std::string::npos);
177 ASSERT_TRUE(str.find("y.y.z") == std::string::npos);
178 cleanup();
179}
Here is the call graph for this function:

◆ TEST() [6/6]

TEST ( logging ,
no_logs  )

Definition at line 98 of file logging.cpp.

99{
100 init();
102 log();
103 std::string str;
104 ASSERT_TRUE(load_log_to_string(log_filename, str));
105 ASSERT_TRUE(str == "");
106 cleanup();
107}
Here is the call graph for this function: