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 #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 11 matching lines...) Expand all Loading... |
22 #include "chrome/common/all_messages.h" | 22 #include "chrome/common/all_messages.h" |
23 #endif | 23 #endif |
24 | 24 |
25 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
26 #include <windows.h> | 26 #include <windows.h> |
27 #endif | 27 #endif |
28 | 28 |
29 #include "chrome/common/logging_chrome.h" | 29 #include "chrome/common/logging_chrome.h" |
30 | 30 |
31 #include <fstream> // NOLINT | 31 #include <fstream> // NOLINT |
| 32 #include <memory> // NOLINT |
32 #include <string> // NOLINT | 33 #include <string> // NOLINT |
33 | 34 |
34 #include "base/base_switches.h" | 35 #include "base/base_switches.h" |
35 #include "base/command_line.h" | 36 #include "base/command_line.h" |
36 #include "base/compiler_specific.h" | 37 #include "base/compiler_specific.h" |
37 #include "base/debug/debugger.h" | 38 #include "base/debug/debugger.h" |
38 #include "base/debug/dump_without_crashing.h" | 39 #include "base/debug/dump_without_crashing.h" |
39 #include "base/environment.h" | 40 #include "base/environment.h" |
40 #include "base/files/file_path.h" | 41 #include "base/files/file_path.h" |
41 #include "base/files/file_util.h" | 42 #include "base/files/file_util.h" |
42 #include "base/memory/scoped_ptr.h" | |
43 #include "base/path_service.h" | 43 #include "base/path_service.h" |
44 #include "base/strings/string_number_conversions.h" | 44 #include "base/strings/string_number_conversions.h" |
45 #include "base/strings/string_util.h" | 45 #include "base/strings/string_util.h" |
46 #include "base/strings/stringprintf.h" | 46 #include "base/strings/stringprintf.h" |
47 #include "base/strings/utf_string_conversions.h" | 47 #include "base/strings/utf_string_conversions.h" |
48 #include "base/threading/thread_restrictions.h" | 48 #include "base/threading/thread_restrictions.h" |
49 #include "chrome/common/chrome_constants.h" | 49 #include "chrome/common/chrome_constants.h" |
50 #include "chrome/common/chrome_paths.h" | 50 #include "chrome/common/chrome_paths.h" |
51 #include "chrome/common/chrome_switches.h" | 51 #include "chrome/common/chrome_switches.h" |
52 #include "chrome/common/env_vars.h" | 52 #include "chrome/common/env_vars.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 DPLOG(WARNING) << "Unable to unlink symlink " << link_path.value(); | 185 DPLOG(WARNING) << "Unable to unlink symlink " << link_path.value(); |
186 if (::unlink(target_path.value().c_str()) == -1) | 186 if (::unlink(target_path.value().c_str()) == -1) |
187 DPLOG(WARNING) << "Unable to unlink log file " << target_path.value(); | 187 DPLOG(WARNING) << "Unable to unlink log file " << target_path.value(); |
188 } | 188 } |
189 | 189 |
190 } // anonymous namespace | 190 } // anonymous namespace |
191 | 191 |
192 base::FilePath GetSessionLogDir(const base::CommandLine& command_line) { | 192 base::FilePath GetSessionLogDir(const base::CommandLine& command_line) { |
193 base::FilePath log_dir; | 193 base::FilePath log_dir; |
194 std::string log_dir_str; | 194 std::string log_dir_str; |
195 scoped_ptr<base::Environment> env(base::Environment::Create()); | 195 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
196 if (env->GetVar(env_vars::kSessionLogDir, &log_dir_str) && | 196 if (env->GetVar(env_vars::kSessionLogDir, &log_dir_str) && |
197 !log_dir_str.empty()) { | 197 !log_dir_str.empty()) { |
198 log_dir = base::FilePath(log_dir_str); | 198 log_dir = base::FilePath(log_dir_str); |
199 } else if (command_line.HasSwitch(chromeos::switches::kLoginProfile)) { | 199 } else if (command_line.HasSwitch(chromeos::switches::kLoginProfile)) { |
200 PathService::Get(chrome::DIR_USER_DATA, &log_dir); | 200 PathService::Get(chrome::DIR_USER_DATA, &log_dir); |
201 base::FilePath profile_dir; | 201 base::FilePath profile_dir; |
202 std::string login_profile_value = | 202 std::string login_profile_value = |
203 command_line.GetSwitchValueASCII(chromeos::switches::kLoginProfile); | 203 command_line.GetSwitchValueASCII(chromeos::switches::kLoginProfile); |
204 if (login_profile_value == chrome::kLegacyProfileDir || | 204 if (login_profile_value == chrome::kLegacyProfileDir || |
205 login_profile_value == chrome::kTestUserProfileDir) { | 205 login_profile_value == chrome::kTestUserProfileDir) { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 // we want process and thread IDs because we have a lot of things running | 324 // we want process and thread IDs because we have a lot of things running |
325 logging::SetLogItems(true, // enable_process_id | 325 logging::SetLogItems(true, // enable_process_id |
326 true, // enable_thread_id | 326 true, // enable_thread_id |
327 true, // enable_timestamp | 327 true, // enable_timestamp |
328 false); // enable_tickcount | 328 false); // enable_tickcount |
329 | 329 |
330 // We call running in unattended mode "headless", and allow | 330 // We call running in unattended mode "headless", and allow |
331 // headless mode to be configured either by the Environment | 331 // headless mode to be configured either by the Environment |
332 // Variable or by the Command Line Switch. This is for | 332 // Variable or by the Command Line Switch. This is for |
333 // automated test purposes. | 333 // automated test purposes. |
334 scoped_ptr<base::Environment> env(base::Environment::Create()); | 334 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
335 if (env->HasVar(env_vars::kHeadless) || | 335 if (env->HasVar(env_vars::kHeadless) || |
336 command_line.HasSwitch(switches::kNoErrorDialogs)) | 336 command_line.HasSwitch(switches::kNoErrorDialogs)) |
337 SuppressDialogs(); | 337 SuppressDialogs(); |
338 | 338 |
339 // Use a minimum log level if the command line asks for one. Ignore this | 339 // Use a minimum log level if the command line asks for one. Ignore this |
340 // switch if there's vlog level switch present too (as both of these switches | 340 // switch if there's vlog level switch present too (as both of these switches |
341 // refer to the same underlying log level, and the vlog level switch has | 341 // refer to the same underlying log level, and the vlog level switch has |
342 // already been processed inside logging::InitLogging). If there is neither | 342 // already been processed inside logging::InitLogging). If there is neither |
343 // log level nor vlog level specified, then just leave the default level | 343 // log level nor vlog level specified, then just leave the default level |
344 // (INFO). | 344 // (INFO). |
(...skipping 28 matching lines...) Expand all Loading... |
373 "Attempted to clean up logging when it wasn't initialized."; | 373 "Attempted to clean up logging when it wasn't initialized."; |
374 | 374 |
375 CloseLogFile(); | 375 CloseLogFile(); |
376 | 376 |
377 chrome_logging_initialized_ = false; | 377 chrome_logging_initialized_ = false; |
378 chrome_logging_redirected_ = false; | 378 chrome_logging_redirected_ = false; |
379 } | 379 } |
380 | 380 |
381 base::FilePath GetLogFileName() { | 381 base::FilePath GetLogFileName() { |
382 std::string filename; | 382 std::string filename; |
383 scoped_ptr<base::Environment> env(base::Environment::Create()); | 383 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
384 if (env->GetVar(env_vars::kLogFileName, &filename) && !filename.empty()) | 384 if (env->GetVar(env_vars::kLogFileName, &filename) && !filename.empty()) |
385 return base::FilePath::FromUTF8Unsafe(filename); | 385 return base::FilePath::FromUTF8Unsafe(filename); |
386 | 386 |
387 const base::FilePath log_filename(FILE_PATH_LITERAL("chrome_debug.log")); | 387 const base::FilePath log_filename(FILE_PATH_LITERAL("chrome_debug.log")); |
388 base::FilePath log_path; | 388 base::FilePath log_path; |
389 | 389 |
390 if (PathService::Get(chrome::DIR_LOGS, &log_path)) { | 390 if (PathService::Get(chrome::DIR_LOGS, &log_path)) { |
391 log_path = log_path.Append(log_filename); | 391 log_path = log_path.Append(log_filename); |
392 return log_path; | 392 return log_path; |
393 } else { | 393 } else { |
(...skipping 13 matching lines...) Expand all Loading... |
407 time_deets.year, | 407 time_deets.year, |
408 time_deets.month, | 408 time_deets.month, |
409 time_deets.day_of_month, | 409 time_deets.day_of_month, |
410 time_deets.hour, | 410 time_deets.hour, |
411 time_deets.minute, | 411 time_deets.minute, |
412 time_deets.second); | 412 time_deets.second); |
413 return base_path.InsertBeforeExtensionASCII(suffix); | 413 return base_path.InsertBeforeExtensionASCII(suffix); |
414 } | 414 } |
415 | 415 |
416 } // namespace logging | 416 } // namespace logging |
OLD | NEW |