| 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 <windows.h> | 5 #include <windows.h> |
| 6 | 6 |
| 7 #include "chrome/installer/util/logging_installer.h" | 7 #include "chrome/installer/util/logging_installer.h" |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 void InitInstallerLogging(const CommandLine& command_line) { | 22 void InitInstallerLogging(const CommandLine& command_line) { |
| 23 if (installer_logging_) | 23 if (installer_logging_) |
| 24 return; | 24 return; |
| 25 | 25 |
| 26 if (command_line.HasSwitch( | 26 if (command_line.HasSwitch( |
| 27 WideToASCII(installer_util::switches::kDisableLogging))) { | 27 WideToASCII(installer_util::switches::kDisableLogging))) { |
| 28 installer_logging_ = true; | 28 installer_logging_ = true; |
| 29 return; | 29 return; |
| 30 } | 30 } |
| 31 | 31 |
| 32 logging::InitLogging(GetLogFilePath(command_line).c_str(), | 32 logging::InitLogging(GetLogFilePath(command_line).value().c_str(), |
| 33 logging::LOG_ONLY_TO_FILE, | 33 logging::LOG_ONLY_TO_FILE, |
| 34 logging::LOCK_LOG_FILE, | 34 logging::LOCK_LOG_FILE, |
| 35 logging::DELETE_OLD_LOG_FILE); | 35 logging::DELETE_OLD_LOG_FILE); |
| 36 | 36 |
| 37 if (command_line.HasSwitch( | 37 if (command_line.HasSwitch( |
| 38 WideToASCII(installer_util::switches::kVerboseLogging))) { | 38 WideToASCII(installer_util::switches::kVerboseLogging))) { |
| 39 logging::SetMinLogLevel(logging::LOG_INFO); | 39 logging::SetMinLogLevel(logging::LOG_INFO); |
| 40 } else { | 40 } else { |
| 41 logging::SetMinLogLevel(logging::LOG_ERROR); | 41 logging::SetMinLogLevel(logging::LOG_ERROR); |
| 42 } | 42 } |
| 43 | 43 |
| 44 installer_logging_ = true; | 44 installer_logging_ = true; |
| 45 } | 45 } |
| 46 | 46 |
| 47 void EndInstallerLogging() { | 47 void EndInstallerLogging() { |
| 48 logging::CloseLogFile(); | 48 logging::CloseLogFile(); |
| 49 | 49 |
| 50 installer_logging_ = false; | 50 installer_logging_ = false; |
| 51 } | 51 } |
| 52 | 52 |
| 53 std::wstring GetLogFilePath(const CommandLine& command_line) { | 53 FilePath GetLogFilePath(const CommandLine& command_line) { |
| 54 if (command_line.HasSwitch( | 54 if (command_line.HasSwitch( |
| 55 WideToASCII(installer_util::switches::kLogFile))) { | 55 WideToASCII(installer_util::switches::kLogFile))) { |
| 56 return command_line.GetSwitchValue( | 56 return command_line.GetSwitchValuePath( |
| 57 WideToASCII(installer_util::switches::kLogFile)); | 57 WideToASCII(installer_util::switches::kLogFile)); |
| 58 } | 58 } |
| 59 | 59 |
| 60 std::wstring log_filename; | 60 std::wstring log_filename; |
| 61 if (command_line.HasSwitch(installer_util::switches::kChromeFrame)) { | 61 if (command_line.HasSwitch(installer_util::switches::kChromeFrame)) { |
| 62 log_filename = L"chrome_frame_installer.log"; | 62 log_filename = L"chrome_frame_installer.log"; |
| 63 } else { | 63 } else { |
| 64 log_filename = L"chrome_installer.log"; | 64 log_filename = L"chrome_installer.log"; |
| 65 } | 65 } |
| 66 | 66 |
| 67 FilePath log_path; | 67 FilePath log_path; |
| 68 | |
| 69 if (PathService::Get(base::DIR_TEMP, &log_path)) { | 68 if (PathService::Get(base::DIR_TEMP, &log_path)) { |
| 70 log_path = log_path.Append(log_filename); | 69 log_path = log_path.Append(log_filename); |
| 71 return log_path.ToWStringHack(); | 70 return log_path; |
| 72 } else { | 71 } else { |
| 73 return log_filename; | 72 return FilePath(log_filename); |
| 74 } | 73 } |
| 75 } | 74 } |
| 76 | 75 |
| 77 } // namespace installer | 76 } // namespace installer |
| OLD | NEW |