| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Note: this test tests LOG_V and LOG_E since all other logs are expressed | 5 // Note: this test tests LOG_V and LOG_E since all other logs are expressed |
| 6 // in forms of them. LOG is also tested for good measure. | 6 // in forms of them. LOG is also tested for good measure. |
| 7 // Also note that we are only allowed to call InitLogging() twice so the test | 7 // Also note that we are only allowed to call InitLogging() twice so the test |
| 8 // cases are more dense than normal. | 8 // cases are more dense than normal. |
| 9 | 9 |
| 10 // The following include must be first in this file. It ensures that | 10 // The following include must be first in this file. It ensures that |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 if (verbosity_level != kDefaultVerbosity) { | 51 if (verbosity_level != kDefaultVerbosity) { |
| 52 // Update the command line with specified verbosity level for this file. | 52 // Update the command line with specified verbosity level for this file. |
| 53 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 53 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 54 std::ostringstream value_stream; | 54 std::ostringstream value_stream; |
| 55 value_stream << "logging_unittest=" << verbosity_level; | 55 value_stream << "logging_unittest=" << verbosity_level; |
| 56 const std::string& value = value_stream.str(); | 56 const std::string& value = value_stream.str(); |
| 57 command_line->AppendSwitchASCII("vmodule", value); | 57 command_line->AppendSwitchASCII("vmodule", value); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // The command line flags are parsed here and the log file name is set. | 60 // The command line flags are parsed here and the log file name is set. |
| 61 if (!InitLogging(log_file_name, logging::LOG_ONLY_TO_FILE, | 61 logging::LoggingSettings settings; |
| 62 logging::DONT_LOCK_LOG_FILE, logging::DELETE_OLD_LOG_FILE, | 62 settings.logging_dest = logging::LOG_TO_FILE; |
| 63 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS)) { | 63 settings.log_file = log_file_name; |
| 64 settings.lock_log = logging::DONT_LOCK_LOG_FILE; |
| 65 settings.delete_old = logging::DELETE_OLD_LOG_FILE; |
| 66 if (!logging::InitLogging(settings)) { |
| 64 return false; | 67 return false; |
| 65 } | 68 } |
| 66 EXPECT_TRUE(VLOG_IS_ON(verbosity_level)); | 69 EXPECT_TRUE(VLOG_IS_ON(verbosity_level)); |
| 67 EXPECT_FALSE(VLOG_IS_ON(verbosity_level + 1)); | 70 EXPECT_FALSE(VLOG_IS_ON(verbosity_level + 1)); |
| 68 return true; | 71 return true; |
| 69 } | 72 } |
| 70 | 73 |
| 71 TEST(LibjingleLogTest, DefaultConfiguration) { | 74 TEST(LibjingleLogTest, DefaultConfiguration) { |
| 72 ASSERT_TRUE(Initialize(kDefaultVerbosity)); | 75 ASSERT_TRUE(Initialize(kDefaultVerbosity)); |
| 73 | 76 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 EXPECT_TRUE(ContainsString(contents_of_file, | 152 EXPECT_TRUE(ContainsString(contents_of_file, |
| 150 AsString(talk_base::LS_WARNING))); | 153 AsString(talk_base::LS_WARNING))); |
| 151 EXPECT_TRUE(ContainsString(contents_of_file, AsString(talk_base::LS_INFO))); | 154 EXPECT_TRUE(ContainsString(contents_of_file, AsString(talk_base::LS_INFO))); |
| 152 // LOG_E | 155 // LOG_E |
| 153 EXPECT_TRUE(ContainsString(contents_of_file, strerror(kFakeError))); | 156 EXPECT_TRUE(ContainsString(contents_of_file, strerror(kFakeError))); |
| 154 EXPECT_TRUE(ContainsString(contents_of_file, | 157 EXPECT_TRUE(ContainsString(contents_of_file, |
| 155 AsString(talk_base::LS_VERBOSE))); | 158 AsString(talk_base::LS_VERBOSE))); |
| 156 EXPECT_TRUE(ContainsString(contents_of_file, | 159 EXPECT_TRUE(ContainsString(contents_of_file, |
| 157 AsString(talk_base::LS_SENSITIVE))); | 160 AsString(talk_base::LS_SENSITIVE))); |
| 158 } | 161 } |
| OLD | NEW |