| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 // Need to include this before most other files because it defines | 7 // Need to include this before most other files because it defines |
| 8 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define | 8 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define |
| 9 // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the | 9 // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the |
| 10 // ViewMsgLog et al. functions. | 10 // ViewMsgLog et al. functions. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG; | 110 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG; |
| 111 #endif | 111 #endif |
| 112 | 112 |
| 113 if (command_line.HasSwitch(kInvertLoggingSwitch)) | 113 if (command_line.HasSwitch(kInvertLoggingSwitch)) |
| 114 enable_logging = !enable_logging; | 114 enable_logging = !enable_logging; |
| 115 | 115 |
| 116 logging::LoggingDestination log_mode; | 116 logging::LoggingDestination log_mode; |
| 117 if (enable_logging) { | 117 if (enable_logging) { |
| 118 // Let --enable-logging=stderr force only stderr, particularly useful for | 118 // Let --enable-logging=stderr force only stderr, particularly useful for |
| 119 // non-debug builds where otherwise you can't get logs to stderr at all. | 119 // non-debug builds where otherwise you can't get logs to stderr at all. |
| 120 if (command_line.GetSwitchValue(switches::kEnableLogging) == L"stderr") | 120 if (command_line.GetSwitchValueASCII(switches::kEnableLogging) == "stderr") |
| 121 log_mode = logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG; | 121 log_mode = logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG; |
| 122 else | 122 else |
| 123 log_mode = kDefaultLoggingMode; | 123 log_mode = kDefaultLoggingMode; |
| 124 } else { | 124 } else { |
| 125 log_mode = logging::LOG_NONE; | 125 log_mode = logging::LOG_NONE; |
| 126 } | 126 } |
| 127 | 127 |
| 128 logging::InitLogging(GetLogFileName().value().c_str(), | 128 logging::InitLogging(GetLogFileName().value().c_str(), |
| 129 log_mode, | 129 log_mode, |
| 130 logging::LOCK_LOG_FILE, | 130 logging::LOCK_LOG_FILE, |
| 131 delete_old_log_file); | 131 delete_old_log_file); |
| 132 | 132 |
| 133 // we want process and thread IDs because we have a lot of things running | 133 // we want process and thread IDs because we have a lot of things running |
| 134 logging::SetLogItems(true, true, false, true); | 134 logging::SetLogItems(true, true, false, true); |
| 135 | 135 |
| 136 // We call running in unattended mode "headless", and allow | 136 // We call running in unattended mode "headless", and allow |
| 137 // headless mode to be configured either by the Environment | 137 // headless mode to be configured either by the Environment |
| 138 // Variable or by the Command Line Switch. This is for | 138 // Variable or by the Command Line Switch. This is for |
| 139 // automated test purposes. | 139 // automated test purposes. |
| 140 if (base::SysInfo::HasEnvVar(env_vars::kHeadless) || | 140 if (base::SysInfo::HasEnvVar(env_vars::kHeadless) || |
| 141 command_line.HasSwitch(switches::kNoErrorDialogs)) | 141 command_line.HasSwitch(switches::kNoErrorDialogs)) |
| 142 SuppressDialogs(); | 142 SuppressDialogs(); |
| 143 | 143 |
| 144 std::wstring log_filter_prefix = | 144 std::string log_filter_prefix = |
| 145 command_line.GetSwitchValue(switches::kLogFilterPrefix); | 145 command_line.GetSwitchValueASCII(switches::kLogFilterPrefix); |
| 146 logging::SetLogFilterPrefix(WideToUTF8(log_filter_prefix).c_str()); | 146 logging::SetLogFilterPrefix(log_filter_prefix.c_str()); |
| 147 | 147 |
| 148 // Use a minimum log level if the command line has one, otherwise set the | 148 // Use a minimum log level if the command line has one, otherwise set the |
| 149 // default to LOG_WARNING. | 149 // default to LOG_WARNING. |
| 150 std::wstring log_level = command_line.GetSwitchValue(switches::kLoggingLevel); | 150 std::string log_level = command_line.GetSwitchValueASCII( |
| 151 switches::kLoggingLevel); |
| 151 int level = 0; | 152 int level = 0; |
| 152 if (StringToInt(WideToUTF16Hack(log_level), &level)) { | 153 if (StringToInt(log_level, &level)) { |
| 153 if ((level >= 0) && (level < LOG_NUM_SEVERITIES)) | 154 if ((level >= 0) && (level < LOG_NUM_SEVERITIES)) |
| 154 logging::SetMinLogLevel(level); | 155 logging::SetMinLogLevel(level); |
| 155 } else { | 156 } else { |
| 156 logging::SetMinLogLevel(LOG_WARNING); | 157 logging::SetMinLogLevel(LOG_WARNING); |
| 157 } | 158 } |
| 158 | 159 |
| 159 chrome_logging_initialized_ = true; | 160 chrome_logging_initialized_ = true; |
| 160 } | 161 } |
| 161 | 162 |
| 162 // This is a no-op, but we'll keep it around in case | 163 // This is a no-op, but we'll keep it around in case |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 assertions->push_back(wide_line); | 214 assertions->push_back(wide_line); |
| 214 ++assertion_count; | 215 ++assertion_count; |
| 215 } | 216 } |
| 216 } | 217 } |
| 217 log_file.close(); | 218 log_file.close(); |
| 218 | 219 |
| 219 return assertion_count; | 220 return assertion_count; |
| 220 } | 221 } |
| 221 | 222 |
| 222 } // namespace logging | 223 } // namespace logging |
| OLD | NEW |