win: Print crash service's log to file.
This commit is contained in:
parent
6f8c46d2f4
commit
edd2bd74c9
1 changed files with 35 additions and 5 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "base/at_exit.h"
|
#include "base/at_exit.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
|
#include "base/file_util.h"
|
||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
@ -13,19 +14,48 @@
|
||||||
|
|
||||||
namespace crash_service {
|
namespace crash_service {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
const wchar_t kStandardLogFile[] = L"operation_log.txt";
|
||||||
|
|
||||||
|
bool GetCrashServiceDirectory(base::FilePath* dir) {
|
||||||
|
base::FilePath temp_dir;
|
||||||
|
if (!file_util::GetTempDir(&temp_dir))
|
||||||
|
return false;
|
||||||
|
temp_dir = temp_dir.Append(L"atom_crashes");
|
||||||
|
if (!file_util::PathExists(temp_dir)) {
|
||||||
|
if (!file_util::CreateDirectory(temp_dir))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*dir = temp_dir;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace.
|
||||||
|
|
||||||
int Main(const wchar_t* cmd_line) {
|
int Main(const wchar_t* cmd_line) {
|
||||||
// Initialize all Chromium things.
|
// Initialize all Chromium things.
|
||||||
base::AtExitManager exit_manager;
|
base::AtExitManager exit_manager;
|
||||||
CommandLine::Init(0, NULL);
|
CommandLine::Init(0, NULL);
|
||||||
|
|
||||||
|
// We use/create a directory under the user's temp folder, for logging.
|
||||||
|
base::FilePath operating_dir;
|
||||||
|
GetCrashServiceDirectory(&operating_dir);
|
||||||
|
base::FilePath log_file = operating_dir.Append(kStandardLogFile);
|
||||||
|
|
||||||
|
// Logging out to a file.
|
||||||
|
logging::InitLogging(
|
||||||
|
log_file.value().c_str(),
|
||||||
|
logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG ,
|
||||||
|
logging::LOCK_LOG_FILE,
|
||||||
|
logging::DELETE_OLD_LOG_FILE,
|
||||||
|
logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
|
||||||
|
logging::SetLogItems(true, false, true, false);
|
||||||
|
|
||||||
VLOG(1) << "Session start. cmdline is [" << cmd_line << "]";
|
VLOG(1) << "Session start. cmdline is [" << cmd_line << "]";
|
||||||
|
|
||||||
wchar_t temp_dir[MAX_PATH] = { 0 };
|
|
||||||
::GetTempPathW(MAX_PATH, temp_dir);
|
|
||||||
base::FilePath temp_path(temp_dir);
|
|
||||||
|
|
||||||
breakpad::CrashService crash_service;
|
breakpad::CrashService crash_service;
|
||||||
if (!crash_service.Initialize(temp_path, temp_path))
|
if (!crash_service.Initialize(operating_dir, operating_dir))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
VLOG(1) << "Ready to process crash requests";
|
VLOG(1) << "Ready to process crash requests";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue