Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: chrome/common/logging_chrome.cc

Issue 329853010: Additional methods for chrome.logPrivate API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 // Need to include this before most other files because it defines 7 // Need to include this before most other files because it defines
8 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define 8 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define
9 // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the 9 // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the
10 // ViewMsgLog et al. functions. 10 // ViewMsgLog et al. functions.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 void RemoveSymlinkAndLog(const base::FilePath& link_path, 180 void RemoveSymlinkAndLog(const base::FilePath& link_path,
181 const base::FilePath& target_path) { 181 const base::FilePath& target_path) {
182 if (::unlink(link_path.value().c_str()) == -1) 182 if (::unlink(link_path.value().c_str()) == -1)
183 DPLOG(WARNING) << "Unable to unlink symlink " << link_path.value(); 183 DPLOG(WARNING) << "Unable to unlink symlink " << link_path.value();
184 if (::unlink(target_path.value().c_str()) == -1) 184 if (::unlink(target_path.value().c_str()) == -1)
185 DPLOG(WARNING) << "Unable to unlink log file " << target_path.value(); 185 DPLOG(WARNING) << "Unable to unlink log file " << target_path.value();
186 } 186 }
187 187
188 } // anonymous namespace 188 } // anonymous namespace
189 189
190 base::FilePath GetSessionLogFile(const CommandLine& command_line) { 190 base::FilePath GetSessionLogDir(const CommandLine& command_line) {
191 base::FilePath log_dir; 191 base::FilePath log_dir;
192 std::string log_dir_str; 192 std::string log_dir_str;
193 scoped_ptr<base::Environment> env(base::Environment::Create()); 193 scoped_ptr<base::Environment> env(base::Environment::Create());
194 if (env->GetVar(env_vars::kSessionLogDir, &log_dir_str) && 194 if (env->GetVar(env_vars::kSessionLogDir, &log_dir_str) &&
195 !log_dir_str.empty()) { 195 !log_dir_str.empty()) {
196 log_dir = base::FilePath(log_dir_str); 196 log_dir = base::FilePath(log_dir_str);
197 } else if (command_line.HasSwitch(chromeos::switches::kLoginProfile)) { 197 } else if (command_line.HasSwitch(chromeos::switches::kLoginProfile)) {
198 PathService::Get(chrome::DIR_USER_DATA, &log_dir); 198 PathService::Get(chrome::DIR_USER_DATA, &log_dir);
199 base::FilePath profile_dir; 199 base::FilePath profile_dir;
200 std::string login_profile_value = 200 std::string login_profile_value =
201 command_line.GetSwitchValueASCII(chromeos::switches::kLoginProfile); 201 command_line.GetSwitchValueASCII(chromeos::switches::kLoginProfile);
202 if (login_profile_value == chrome::kLegacyProfileDir || 202 if (login_profile_value == chrome::kLegacyProfileDir ||
203 login_profile_value == chrome::kTestUserProfileDir) { 203 login_profile_value == chrome::kTestUserProfileDir) {
204 profile_dir = base::FilePath(login_profile_value); 204 profile_dir = base::FilePath(login_profile_value);
205 } else { 205 } else {
206 // We could not use g_browser_process > profile_helper() here. 206 // We could not use g_browser_process > profile_helper() here.
207 std::string profile_dir_str = chrome::kProfileDirPrefix; 207 std::string profile_dir_str = chrome::kProfileDirPrefix;
208 profile_dir_str.append(login_profile_value); 208 profile_dir_str.append(login_profile_value);
209 profile_dir = base::FilePath(profile_dir_str); 209 profile_dir = base::FilePath(profile_dir_str);
210 } 210 }
211 log_dir = log_dir.Append(profile_dir); 211 log_dir = log_dir.Append(profile_dir);
212 } 212 }
213 return log_dir.Append(GetLogFileName().BaseName()); 213 return log_dir;
214 }
215
216 base::FilePath GetSessionLogFile(const CommandLine& command_line) {
217 return GetSessionLogDir(command_line).Append(GetLogFileName().BaseName());
214 } 218 }
215 219
216 void RedirectChromeLogging(const CommandLine& command_line) { 220 void RedirectChromeLogging(const CommandLine& command_line) {
217 if (chrome_logging_redirected_) { 221 if (chrome_logging_redirected_) {
218 // TODO(nkostylev): Support multiple active users. http://crbug.com/230345 222 // TODO(nkostylev): Support multiple active users. http://crbug.com/230345
219 LOG(WARNING) << "NOT redirecting logging for multi-profiles case."; 223 LOG(WARNING) << "NOT redirecting logging for multi-profiles case.";
220 return; 224 return;
221 } 225 }
222 226
223 DCHECK(!chrome_logging_redirected_) << 227 DCHECK(!chrome_logging_redirected_) <<
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 time_deets.year, 428 time_deets.year,
425 time_deets.month, 429 time_deets.month,
426 time_deets.day_of_month, 430 time_deets.day_of_month,
427 time_deets.hour, 431 time_deets.hour,
428 time_deets.minute, 432 time_deets.minute,
429 time_deets.second); 433 time_deets.second);
430 return base_path.InsertBeforeExtensionASCII(suffix); 434 return base_path.InsertBeforeExtensionASCII(suffix);
431 } 435 }
432 436
433 } // namespace logging 437 } // namespace logging
OLDNEW
« no previous file with comments | « chrome/common/logging_chrome.h ('k') | chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698