< prev index next >

test/native/logging/test_logConfiguration.cpp

Print this page
rev 11857 : imported patch 8150823


 147 TEST_F(LogConfigurationTest, add_new_output) {
 148   const char* what = "all=trace";
 149 
 150   ASSERT_FALSE(is_described(TestLogFileName));
 151   set_log_config(TestLogFileName, what);
 152 
 153   // Verify new output using LogConfiguration::describe
 154   EXPECT_TRUE(is_described(TestLogFileName));
 155   EXPECT_TRUE(is_described("logging=trace"));
 156 
 157   // Also verify by iterating over tagsets, checking levels on tagsets
 158   for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) {
 159     EXPECT_TRUE(ts->is_level(LogLevel::Trace));
 160   }
 161 }
 162 
 163 TEST_F(LogConfigurationTest, disable_logging) {
 164   // Add TestLogFileName as an output
 165   set_log_config(TestLogFileName, "logging=info");
 166 





 167   LogConfiguration::disable_logging();
 168 
 169   // Verify TestLogFileName was disabled
 170   EXPECT_FALSE(is_described(TestLogFileName));


 171 
 172   // Verify that no tagset has logging enabled
 173   for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) {
 174     EXPECT_FALSE(ts->has_output(LogOutput::Stdout));
 175     EXPECT_FALSE(ts->has_output(LogOutput::Stderr));
 176     EXPECT_FALSE(ts->is_level(LogLevel::Error));
 177   }
 178 }
 179 
 180 // Test disabling a particular output
 181 TEST_F(LogConfigurationTest, disable_output) {
 182   // Disable the default configuration for stdout
 183   set_log_config("stdout", "all=off");
 184 
 185   // Verify configuration using LogConfiguration::describe
 186   EXPECT_TRUE(is_described("#0: stdout all=off"));
 187 
 188   // Verify by iterating over tagsets
 189   LogOutput* o = LogOutput::Stdout;
 190   for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) {




 147 TEST_F(LogConfigurationTest, add_new_output) {
 148   const char* what = "all=trace";
 149 
 150   ASSERT_FALSE(is_described(TestLogFileName));
 151   set_log_config(TestLogFileName, what);
 152 
 153   // Verify new output using LogConfiguration::describe
 154   EXPECT_TRUE(is_described(TestLogFileName));
 155   EXPECT_TRUE(is_described("logging=trace"));
 156 
 157   // Also verify by iterating over tagsets, checking levels on tagsets
 158   for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) {
 159     EXPECT_TRUE(ts->is_level(LogLevel::Trace));
 160   }
 161 }
 162 
 163 TEST_F(LogConfigurationTest, disable_logging) {
 164   // Add TestLogFileName as an output
 165   set_log_config(TestLogFileName, "logging=info");
 166 
 167   // Add a second file output
 168   char other_file_name[2 * K];
 169   jio_snprintf(other_file_name, sizeof(other_file_name), "%s-other", TestLogFileName);
 170   set_log_config(other_file_name, "logging=info");
 171 
 172   LogConfiguration::disable_logging();
 173 
 174   // Verify that both file outputs were disabled
 175   EXPECT_FALSE(is_described(TestLogFileName));
 176   EXPECT_FALSE(is_described(other_file_name));
 177   delete_file(other_file_name);
 178 
 179   // Verify that no tagset has logging enabled
 180   for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) {
 181     EXPECT_FALSE(ts->has_output(LogOutput::Stdout));
 182     EXPECT_FALSE(ts->has_output(LogOutput::Stderr));
 183     EXPECT_FALSE(ts->is_level(LogLevel::Error));
 184   }
 185 }
 186 
 187 // Test disabling a particular output
 188 TEST_F(LogConfigurationTest, disable_output) {
 189   // Disable the default configuration for stdout
 190   set_log_config("stdout", "all=off");
 191 
 192   // Verify configuration using LogConfiguration::describe
 193   EXPECT_TRUE(is_described("#0: stdout all=off"));
 194 
 195   // Verify by iterating over tagsets
 196   LogOutput* o = LogOutput::Stdout;
 197   for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) {


< prev index next >