From 02bcdc1c19b87a5f2cb365c39c68726ff6d1b4ae Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 11 Nov 2014 13:30:06 +0800 Subject: [PATCH] linux: Put "uploads.log" under "/tmp/ProductName Crashes/" --- atom/common/crash_reporter/crash_reporter_linux.cc | 5 +++++ atom/common/crash_reporter/linux/crash_dump_handler.cc | 4 +++- atom/common/crash_reporter/linux/crash_dump_handler.h | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/atom/common/crash_reporter/crash_reporter_linux.cc b/atom/common/crash_reporter/crash_reporter_linux.cc index dd7b6b41ba..89e2f7e76a 100644 --- a/atom/common/crash_reporter/crash_reporter_linux.cc +++ b/atom/common/crash_reporter/crash_reporter_linux.cc @@ -17,6 +17,7 @@ #include "base/logging.h" #include "base/process/memory.h" #include "base/memory/singleton.h" +#include "base/strings/stringprintf.h" #include "vendor/breakpad/src/client/linux/handler/exception_handler.h" #include "vendor/breakpad/src/common/linux/linux_libc_support.h" @@ -81,6 +82,10 @@ void CrashReporterLinux::EnableCrashDumping(const std::string& product_name) { base::FilePath dumps_path(dump_dir); base::CreateDirectory(dumps_path); + std::string log_file = base::StringPrintf( + "%s/%s", dump_dir.c_str(), "uploads.log"); + strncpy(g_crash_log_path, log_file.c_str(), sizeof(g_crash_log_path)); + MinidumpDescriptor minidump_descriptor(dumps_path.value()); minidump_descriptor.set_size_limit(kMaxMinidumpFileSize); diff --git a/atom/common/crash_reporter/linux/crash_dump_handler.cc b/atom/common/crash_reporter/linux/crash_dump_handler.cc index 4403d1d803..56a5e094d4 100644 --- a/atom/common/crash_reporter/linux/crash_dump_handler.cc +++ b/atom/common/crash_reporter/linux/crash_dump_handler.cc @@ -441,7 +441,7 @@ void HandleCrashReportId(const char* buf, size_t bytes_read, my_uint64tos(time_str, time, time_len); const int kLogOpenFlags = O_CREAT | O_WRONLY | O_APPEND | O_CLOEXEC; - int log_fd = sys_open("/tmp/uploads.log", kLogOpenFlags, 0600); + int log_fd = sys_open(g_crash_log_path, kLogOpenFlags, 0600); if (log_fd > 0) { sys_write(log_fd, time_str, time_len); sys_write(log_fd, ",", 1); @@ -454,6 +454,8 @@ void HandleCrashReportId(const char* buf, size_t bytes_read, } // namespace +char g_crash_log_path[256]; + void HandleCrashDump(const BreakpadInfo& info) { int dumpfd; bool keep_fd = false; diff --git a/atom/common/crash_reporter/linux/crash_dump_handler.h b/atom/common/crash_reporter/linux/crash_dump_handler.h index e2bb0b6a32..f600c9e0d1 100644 --- a/atom/common/crash_reporter/linux/crash_dump_handler.h +++ b/atom/common/crash_reporter/linux/crash_dump_handler.h @@ -34,6 +34,9 @@ void HandleCrashDump(const BreakpadInfo& info); size_t WriteLog(const char* buf, size_t nbytes); size_t WriteNewline(); +// Global variable storing the path of upload log. +extern char g_crash_log_path[256]; + } // namespace crash_reporter #endif // ATOM_COMMON_CRASH_REPORTER_LINUX_CRASH_DUMP_HANDLER_H_