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