31 #include <boost/filesystem.hpp> 32 #include "gtest/gtest.h" 40 boost::filesystem::path p = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
41 log_filename = p.string();
49 boost::filesystem::remove(log_filename);
56 for (
const char *ptr = str.c_str(); *ptr; ++ptr)
66 for (
const char *ptr = str.c_str(); *ptr; ++ptr)
71 if (prefix.find(
"New log categories:") != std::string::npos)
90 MCINFO(
"a.b.c.d",
"a.b.c.d");
91 MCINFO(
"a.b.c.e",
"a.b.c.e");
92 MCINFO(
"global",
"global");
104 ASSERT_TRUE(load_log_to_string(log_filename, 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);
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);
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);
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);
172 ASSERT_TRUE(load_log_to_string(log_filename, str));
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);
void mlog_configure(const std::string &filename_base, bool console, const std::size_t max_log_file_size=MAX_LOG_FILE_SIZE, const std::size_t max_log_files=MAX_LOG_FILES)
bool load_file_to_string(const std::string &path_to_file, std::string &target_str, size_t max_size=1000000000)
void mlog_set_categories(const char *categories)
#define ASSERT_TRUE(condition)