|
21 | 21 | #include "content/nw/src/shell_main_delegate.h"
|
22 | 22 |
|
23 | 23 | #include "base/command_line.h"
|
| 24 | +#include "base/environment.h" |
24 | 25 | #include "base/files/file_path.h"
|
25 | 26 | #include "base/file_util.h"
|
26 | 27 | #include "base/lazy_instance.h"
|
@@ -111,10 +112,26 @@ base::LazyInstance<ShellContentUtilityClient>
|
111 | 112 | g_chrome_content_utility_client = LAZY_INSTANCE_INITIALIZER;
|
112 | 113 | #endif
|
113 | 114 |
|
| 115 | +base::FilePath GetLogFileName() { |
| 116 | + std::string filename; |
| 117 | + scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 118 | + if (env->GetVar("NWJS_LOG_FILE", &filename) && !filename.empty()) |
| 119 | + return base::FilePath::FromUTF8Unsafe(filename); |
| 120 | + |
| 121 | + const base::FilePath log_filename(FILE_PATH_LITERAL("debug.log")); |
| 122 | + base::FilePath log_path; |
| 123 | + |
| 124 | + if (PathService::Get(base::DIR_EXE, &log_path)) { |
| 125 | + log_path = log_path.Append(log_filename); |
| 126 | + return log_path; |
| 127 | + } else { |
| 128 | + // error with path service, just use some default file somewhere |
| 129 | + return log_filename; |
| 130 | + } |
| 131 | +} |
| 132 | + |
114 | 133 | void InitLogging() {
|
115 |
| - base::FilePath log_filename; |
116 |
| - PathService::Get(base::DIR_EXE, &log_filename); |
117 |
| - log_filename = log_filename.AppendASCII("debug.log"); |
| 134 | + base::FilePath log_filename = GetLogFileName(); |
118 | 135 | logging::LoggingSettings settings;
|
119 | 136 | if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableLogging)) {
|
120 | 137 | settings.logging_dest = logging::LOG_TO_ALL;
|
|
0 commit comments