diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 37ff0507d761..d8ce8170fb0b 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -375,6 +375,8 @@ int GetPathConstant(const std::string& name) { return brightray::DIR_CACHE; else if (name == "userCache") return brightray::DIR_USER_CACHE; + else if (name == "logs") + return brightray::DIR_APP_LOGS; else if (name == "home") return base::DIR_HOME; else if (name == "temp") diff --git a/brightray/browser/brightray_paths.h b/brightray/browser/brightray_paths.h index b12b10d08f3c..56525baeaab7 100644 --- a/brightray/browser/brightray_paths.h +++ b/brightray/browser/brightray_paths.h @@ -22,6 +22,7 @@ enum { DIR_USER_DATA = PATH_START, // Directory where user data can be written. DIR_USER_CACHE, // Directory where user cache can be written. + DIR_APP_LOGS, // Directory where app logs live #if defined(OS_LINUX) DIR_APP_DATA, // Application Data directory under the user profile. diff --git a/brightray/browser/browser_main_parts.cc b/brightray/browser/browser_main_parts.cc index d6336962fef6..a949a236f3a0 100644 --- a/brightray/browser/browser_main_parts.cc +++ b/brightray/browser/browser_main_parts.cc @@ -55,6 +55,8 @@ namespace brightray { +void OverrideMacAppLogsPath(); + namespace { #if defined(OS_WIN) @@ -160,7 +162,9 @@ void BrowserMainParts::PreEarlyInitialization() { std::unique_ptr feature_list(new base::FeatureList); feature_list->InitializeFromCommandLine("", ""); base::FeatureList::SetInstance(std::move(feature_list)); - +#if defined(OS_MACOSX) + OverrideMacAppLogsPath(); +#endif #if defined(USE_X11) views::LinuxUI::SetInstance(BuildGtkUi()); OverrideLinuxAppDataPath(); diff --git a/brightray/browser/browser_main_parts.h b/brightray/browser/browser_main_parts.h index d495e67b5ffa..53d3cf38b720 100644 --- a/brightray/browser/browser_main_parts.h +++ b/brightray/browser/browser_main_parts.h @@ -9,6 +9,8 @@ #include "base/compiler_specific.h" #include "base/macros.h" +#include "base/path_service.h" +#include "brightray/browser/brightray_paths.h" #include "content/public/browser/browser_main_parts.h" #include "ui/views/layout/layout_provider.h" diff --git a/brightray/browser/browser_main_parts_mac.mm b/brightray/browser/browser_main_parts_mac.mm index 5e80eca442be..2e111caafc0e 100644 --- a/brightray/browser/browser_main_parts_mac.mm +++ b/brightray/browser/browser_main_parts_mac.mm @@ -6,6 +6,18 @@ namespace brightray { +void OverrideMacAppLogsPath() { + base::FilePath path; + NSString* bundleName = [[[NSBundle mainBundle] infoDictionary] + objectForKey:@"CFBundleName"]; + NSString* logsPath = [NSString stringWithFormat:@"Library/Logs/%@",bundleName]; + + NSString* libraryPath = [NSHomeDirectory() stringByAppendingPathComponent:logsPath]; + std::string libPathString = std::string([libraryPath UTF8String]); + + PathService::Override(DIR_APP_LOGS, base::FilePath(libPathString)); +} + // Replicates NSApplicationMain, but doesn't start a run loop. void BrowserMainParts::InitializeMainNib() { auto infoDictionary = base::mac::OuterBundle().infoDictionary;