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 #ifndef CHROME_COMMON_LOGGING_CHROME_H__ | 5 #ifndef CHROME_COMMON_LOGGING_CHROME_H__ |
6 #define CHROME_COMMON_LOGGING_CHROME_H__ | 6 #define CHROME_COMMON_LOGGING_CHROME_H__ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 | 13 |
14 class CommandLine; | 14 class CommandLine; |
| 15 |
| 16 namespace base { |
15 class FilePath; | 17 class FilePath; |
| 18 } |
16 | 19 |
17 namespace logging { | 20 namespace logging { |
18 | 21 |
19 // Call to initialize logging for Chrome. This sets up the chrome-specific | 22 // Call to initialize logging for Chrome. This sets up the chrome-specific |
20 // logfile naming scheme and might do other things like log modules and | 23 // logfile naming scheme and might do other things like log modules and |
21 // setting levels in the future. | 24 // setting levels in the future. |
22 // | 25 // |
23 // The main process might want to delete any old log files on startup by | 26 // The main process might want to delete any old log files on startup by |
24 // setting delete_old_log_file, but the renderer processes should not, or | 27 // setting delete_old_log_file, but the renderer processes should not, or |
25 // they will delete each others' logs. | 28 // they will delete each others' logs. |
26 // | 29 // |
27 // XXX | 30 // XXX |
28 // Setting suppress_error_dialogs to true disables any dialogs that would | 31 // Setting suppress_error_dialogs to true disables any dialogs that would |
29 // normally appear for assertions and crashes, and makes any catchable | 32 // normally appear for assertions and crashes, and makes any catchable |
30 // errors (namely assertions) available via GetSilencedErrorCount() | 33 // errors (namely assertions) available via GetSilencedErrorCount() |
31 // and GetSilencedError(). | 34 // and GetSilencedError(). |
32 void InitChromeLogging(const CommandLine& command_line, | 35 void InitChromeLogging(const CommandLine& command_line, |
33 OldFileDeletionState delete_old_log_file); | 36 OldFileDeletionState delete_old_log_file); |
34 | 37 |
35 #if defined(OS_CHROMEOS) | 38 #if defined(OS_CHROMEOS) |
36 // Get the log file location. | 39 // Get the log file location. |
37 FilePath GetSessionLogFile(const CommandLine& command_line); | 40 base::FilePath GetSessionLogFile(const CommandLine& command_line); |
38 | 41 |
39 // Redirects chrome logging to the appropriate session log dir. | 42 // Redirects chrome logging to the appropriate session log dir. |
40 void RedirectChromeLogging(const CommandLine& command_line); | 43 void RedirectChromeLogging(const CommandLine& command_line); |
41 #endif | 44 #endif |
42 | 45 |
43 // Call when done using logging for Chrome. | 46 // Call when done using logging for Chrome. |
44 void CleanupChromeLogging(); | 47 void CleanupChromeLogging(); |
45 | 48 |
46 // Returns the fully-qualified name of the log file. | 49 // Returns the fully-qualified name of the log file. |
47 FilePath GetLogFileName(); | 50 base::FilePath GetLogFileName(); |
48 | 51 |
49 // Returns true when error/assertion dialogs are to be shown, | 52 // Returns true when error/assertion dialogs are to be shown, |
50 // false otherwise. | 53 // false otherwise. |
51 bool DialogsAreSuppressed(); | 54 bool DialogsAreSuppressed(); |
52 | 55 |
53 typedef std::vector<std::wstring> AssertionList; | 56 typedef std::vector<std::wstring> AssertionList; |
54 | 57 |
55 // Gets the list of fatal assertions in the current log file, and | 58 // Gets the list of fatal assertions in the current log file, and |
56 // returns the number of fatal assertions. (If you don't care | 59 // returns the number of fatal assertions. (If you don't care |
57 // about the actual list of assertions, you can pass in NULL.) | 60 // about the actual list of assertions, you can pass in NULL.) |
58 // NOTE: Since this reads the log file to determine the assertions, | 61 // NOTE: Since this reads the log file to determine the assertions, |
59 // this operation is O(n) over the length of the log. | 62 // this operation is O(n) over the length of the log. |
60 // NOTE: This can fail if the file is locked for writing. However, | 63 // NOTE: This can fail if the file is locked for writing. However, |
61 // this is unlikely as this function is most useful after | 64 // this is unlikely as this function is most useful after |
62 // the program writing the log has terminated. | 65 // the program writing the log has terminated. |
63 size_t GetFatalAssertions(AssertionList* assertions); | 66 size_t GetFatalAssertions(AssertionList* assertions); |
64 | 67 |
65 // Inserts timestamp before file extension in the format | 68 // Inserts timestamp before file extension in the format |
66 // "_yymmdd-hhmmss". | 69 // "_yymmdd-hhmmss". |
67 FilePath GenerateTimestampedName(const FilePath& base_path, | 70 base::FilePath GenerateTimestampedName(const base::FilePath& base_path, |
68 base::Time timestamp); | 71 base::Time timestamp); |
69 } // namespace logging | 72 } // namespace logging |
70 | 73 |
71 #endif // CHROME_COMMON_LOGGING_CHROME_H_ | 74 #endif // CHROME_COMMON_LOGGING_CHROME_H_ |
OLD | NEW |