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

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

Issue 10909164: LoggingLock::Init() should append a non-empty string to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Remove base/logging.cc from the CL Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 255
256 void InitChromeLogging(const CommandLine& command_line, 256 void InitChromeLogging(const CommandLine& command_line,
257 OldFileDeletionState delete_old_log_file) { 257 OldFileDeletionState delete_old_log_file) {
258 DCHECK(!chrome_logging_initialized_) << 258 DCHECK(!chrome_logging_initialized_) <<
259 "Attempted to initialize logging when it was already initialized."; 259 "Attempted to initialize logging when it was already initialized.";
260 260
261 #if defined(OS_POSIX) && defined(IPC_MESSAGE_LOG_ENABLED) 261 #if defined(OS_POSIX) && defined(IPC_MESSAGE_LOG_ENABLED)
262 IPC::Logging::set_log_function_map(&g_log_function_mapping); 262 IPC::Logging::set_log_function_map(&g_log_function_mapping);
263 #endif 263 #endif
264 LoggingDestination logging_dest = DetermineLogMode(command_line); 264 LoggingDestination logging_dest = DetermineLogMode(command_line);
265 LogLockingState log_locking_state = LOCK_LOG_FILE;
265 FilePath log_path; 266 FilePath log_path;
266 #if defined(OS_CHROMEOS) 267 #if defined(OS_CHROMEOS)
267 FilePath target_path; 268 FilePath target_path;
268 #endif 269 #endif
269 270
270 // Don't resolve the log path unless we need to. Otherwise we leave an open 271 // Don't resolve the log path unless we need to. Otherwise we leave an open
271 // ALPC handle after sandbox lockdown on Windows. 272 // ALPC handle after sandbox lockdown on Windows.
272 if (logging_dest == LOG_ONLY_TO_FILE || 273 if (logging_dest == LOG_ONLY_TO_FILE ||
273 logging_dest == LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG) { 274 logging_dest == LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG) {
274 log_path = GetLogFileName(); 275 log_path = GetLogFileName();
275 276
276 #if defined(OS_CHROMEOS) 277 #if defined(OS_CHROMEOS)
277 // For BWSI (Incognito) logins, we want to put the logs in the user 278 // For BWSI (Incognito) logins, we want to put the logs in the user
278 // profile directory that is created for the temporary session instead 279 // profile directory that is created for the temporary session instead
279 // of in the system log directory, for privacy reasons. 280 // of in the system log directory, for privacy reasons.
280 if (command_line.HasSwitch(switches::kGuestSession)) 281 if (command_line.HasSwitch(switches::kGuestSession))
281 log_path = GetSessionLogFile(command_line); 282 log_path = GetSessionLogFile(command_line);
282 283
283 // On ChromeOS we log to the symlink. We force creation of a new 284 // On ChromeOS we log to the symlink. We force creation of a new
284 // symlink if we've been asked to delete the old log, since that 285 // symlink if we've been asked to delete the old log, since that
285 // indicates the start of a new session. 286 // indicates the start of a new session.
286 target_path = SetUpSymlinkIfNeeded( 287 target_path = SetUpSymlinkIfNeeded(
287 log_path, delete_old_log_file == logging::DELETE_OLD_LOG_FILE); 288 log_path, delete_old_log_file == logging::DELETE_OLD_LOG_FILE);
288 289
289 // Because ChromeOS manages the move to a new session by redirecting 290 // Because ChromeOS manages the move to a new session by redirecting
290 // the link, it shouldn't remove the old file in the logging code, 291 // the link, it shouldn't remove the old file in the logging code,
291 // since that will remove the newly created link instead. 292 // since that will remove the newly created link instead.
292 delete_old_log_file = logging::APPEND_TO_OLD_LOG_FILE; 293 delete_old_log_file = logging::APPEND_TO_OLD_LOG_FILE;
293 #endif 294 #endif
295 } else {
296 log_locking_state = DONT_LOCK_LOG_FILE;
294 } 297 }
295 298
296 logging::DcheckState dcheck_state = 299 logging::DcheckState dcheck_state =
297 command_line.HasSwitch(switches::kEnableDCHECK) ? 300 command_line.HasSwitch(switches::kEnableDCHECK) ?
298 logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS : 301 logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS :
299 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; 302 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS;
300 303
301 bool success = InitLogging(log_path.value().c_str(), 304 bool success = InitLogging(log_path.value().c_str(),
302 logging_dest, 305 logging_dest,
303 logging::LOCK_LOG_FILE, 306 log_locking_state,
304 delete_old_log_file, 307 delete_old_log_file,
305 dcheck_state); 308 dcheck_state);
306 309
307 #if defined(OS_CHROMEOS) 310 #if defined(OS_CHROMEOS)
308 if (!success) { 311 if (!success) {
309 DPLOG(ERROR) << "Unable to initialize logging to " << log_path.value() 312 DPLOG(ERROR) << "Unable to initialize logging to " << log_path.value()
310 << " (which should be a link to " << target_path.value() << ")"; 313 << " (which should be a link to " << target_path.value() << ")";
311 RemoveSymlinkAndLog(log_path, target_path); 314 RemoveSymlinkAndLog(log_path, target_path);
312 chrome_logging_failed_ = true; 315 chrome_logging_failed_ = true;
313 return; 316 return;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 time_deets.year, 469 time_deets.year,
467 time_deets.month, 470 time_deets.month,
468 time_deets.day_of_month, 471 time_deets.day_of_month,
469 time_deets.hour, 472 time_deets.hour,
470 time_deets.minute, 473 time_deets.minute,
471 time_deets.second); 474 time_deets.second);
472 return base_path.InsertBeforeExtensionASCII(suffix); 475 return base_path.InsertBeforeExtensionASCII(suffix);
473 } 476 }
474 477
475 } // namespace logging 478 } // namespace logging
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698