1 // Copyright (c) 2011 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.
5 #ifndef CHROME_INSTALLER_UTIL_LOGGING_INSTALLER_H_
6 #define CHROME_INSTALLER_UTIL_LOGGING_INSTALLER_H_
8 #include "base/basictypes.h"
16 class MasterPreferences
;
18 // Verbose installer runs clock in at around 50K, non-verbose much less than
19 // that. Some installer operations span multiple setup.exe runs, so we try
20 // to keep enough for at least 10 runs or so at any given time.
21 const int kMaxInstallerLogFileSize
= 1024 * 1024;
23 // Truncate the file down to half of the max, such that we don't incur
24 // truncation on every update.
25 const int kTruncatedInstallerLogFileSize
= kMaxInstallerLogFileSize
/ 2;
27 COMPILE_ASSERT(kTruncatedInstallerLogFileSize
< kMaxInstallerLogFileSize
,
28 kTruncatedInstallerLogFileSize_not_lt_kMaxInstallerLogFileSize
);
36 // Cuts off the _beginning_ of the file at |log_file| down to
37 // kTruncatedInstallerLogFileSize if it exceeds kMaxInstallerLogFileSize bytes.
39 // If the file is not changed, returns LOGFILE_UNTOUCHED.
40 // If the file is successfully truncated, returns LOGFILE_TRUNCATED.
41 // If the file needed truncation, but the truncation failed, the file will be
42 // deleted and the function returns LOGFILE_DELETED. This is done to prevent
43 // run-away log files and guard against full disks.
44 TruncateResult
TruncateLogFileIfNeeded(const base::FilePath
& log_file
);
46 // Call to initialize logging for Chrome installer.
47 void InitInstallerLogging(const installer::MasterPreferences
& prefs
);
49 // Call when done using logging for Chrome installer.
50 void EndInstallerLogging();
52 // Returns the full path of the log file.
53 base::FilePath
GetLogFilePath(const installer::MasterPreferences
& prefs
);
55 } // namespace installer
57 #endif // CHROME_INSTALLER_UTIL_LOGGING_INSTALLER_H_