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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "chrome/installer/util/util_constants.h" | 13 #include "chrome/installer/util/util_constants.h" |
14 | 14 |
15 namespace installer { | 15 namespace installer { |
16 | 16 |
17 // This should be true for the period between the end of | 17 // This should be true for the period between the end of |
18 // InitInstallerLogging() and the beginning of EndInstallerLogging(). | 18 // InitInstallerLogging() and the beginning of EndInstallerLogging(). |
19 bool installer_logging_ = false; | 19 bool installer_logging_ = false; |
20 | 20 |
21 void InitInstallerLogging(const CommandLine& command_line) { | 21 void InitInstallerLogging(const CommandLine& command_line) { |
22 if (installer_logging_) | 22 if (installer_logging_) |
23 return; | 23 return; |
24 | 24 |
25 if (command_line.HasSwitch(installer_util::switches::kDisableLogging)) { | 25 if (command_line.HasSwitch( |
| 26 WideToASCII(installer_util::switches::kDisableLogging))) { |
26 installer_logging_ = true; | 27 installer_logging_ = true; |
27 return; | 28 return; |
28 } | 29 } |
29 | 30 |
30 logging::InitLogging(GetLogFilePath(command_line).c_str(), | 31 logging::InitLogging(GetLogFilePath(command_line).c_str(), |
31 logging::LOG_ONLY_TO_FILE, | 32 logging::LOG_ONLY_TO_FILE, |
32 logging::LOCK_LOG_FILE, | 33 logging::LOCK_LOG_FILE, |
33 logging::DELETE_OLD_LOG_FILE); | 34 logging::DELETE_OLD_LOG_FILE); |
34 | 35 |
35 if (command_line.HasSwitch(installer_util::switches::kVerboseLogging)) { | 36 if (command_line.HasSwitch( |
| 37 WideToASCII(installer_util::switches::kVerboseLogging))) { |
36 logging::SetMinLogLevel(logging::LOG_INFO); | 38 logging::SetMinLogLevel(logging::LOG_INFO); |
37 } else { | 39 } else { |
38 logging::SetMinLogLevel(logging::LOG_ERROR); | 40 logging::SetMinLogLevel(logging::LOG_ERROR); |
39 } | 41 } |
40 | 42 |
41 installer_logging_ = true; | 43 installer_logging_ = true; |
42 } | 44 } |
43 | 45 |
44 void EndInstallerLogging() { | 46 void EndInstallerLogging() { |
45 logging::CloseLogFile(); | 47 logging::CloseLogFile(); |
46 | 48 |
47 installer_logging_ = false; | 49 installer_logging_ = false; |
48 } | 50 } |
49 | 51 |
50 std::wstring GetLogFilePath(const CommandLine& command_line) { | 52 std::wstring GetLogFilePath(const CommandLine& command_line) { |
51 if (command_line.HasSwitch(installer_util::switches::kLogFile)) { | 53 if (command_line.HasSwitch( |
52 return command_line.GetSwitchValue(installer_util::switches::kLogFile); | 54 WideToASCII(installer_util::switches::kLogFile))) { |
| 55 return command_line.GetSwitchValue( |
| 56 WideToASCII(installer_util::switches::kLogFile)); |
53 } | 57 } |
54 | 58 |
55 const std::wstring log_filename(L"chrome_installer.log"); | 59 const std::wstring log_filename(L"chrome_installer.log"); |
56 FilePath log_path; | 60 FilePath log_path; |
57 | 61 |
58 if (PathService::Get(base::DIR_TEMP, &log_path)) { | 62 if (PathService::Get(base::DIR_TEMP, &log_path)) { |
59 log_path = log_path.Append(log_filename); | 63 log_path = log_path.Append(log_filename); |
60 return log_path.ToWStringHack(); | 64 return log_path.ToWStringHack(); |
61 } else { | 65 } else { |
62 return log_filename; | 66 return log_filename; |
63 } | 67 } |
64 } | 68 } |
65 | 69 |
66 } // namespace installer | 70 } // namespace installer |
OLD | NEW |