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

Side by Side Diff: chrome/browser/chromeos/logging.cc

Issue 2901173002: Move RedirectChromeLogging to src/chromeos. (Closed)
Patch Set: Using blocking pool Created 3 years, 6 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/logging.h"
6
7 #include "base/command_line.h"
8 #include "base/files/file_path.h"
9 #include "base/logging.h"
10 #include "chrome/common/logging_chrome.h"
11
12 namespace logging {
13
14 void RedirectChromeLogging(const base::CommandLine& command_line) {
15 // This should be true for exactly the period between the end of
16 // InitChromeLogging() and the beginning of CleanupChromeLogging().
17 static bool chrome_logging_redirected_ = false;
18 if (chrome_logging_redirected_) {
19 // TODO: Support multiple active users. http://crbug.com/230345
20 LOG(WARNING) << "NOT redirecting logging for multi-profiles case.";
21 return;
22 }
23
24 DCHECK(!chrome_logging_redirected_)
25 << "Attempted to redirect logging when it was already initialized.";
26
27 // Redirect logs to the session log directory, if set. Otherwise
28 // defaults to the profile dir.
29 const base::FilePath log_path = GetSessionLogFile(command_line);
30
31 // Always force a new symlink when redirecting.
32 const base::FilePath target_path = SetUpSymlinkIfNeeded(log_path, true);
33
34 // ChromeOS always logs through the symlink, so it shouldn't be
35 // deleted if it already exists.
36 logging::LoggingSettings settings;
37 settings.logging_dest = DetermineLoggingDestination(command_line);
38 settings.log_file = log_path.value().c_str();
39 if (!logging::InitLogging(settings)) {
xiyuan 2017/05/31 15:32:22 Would logging::InitLogging be safe to be called fr
achuithb 2017/05/31 23:42:45 Done.
40 DLOG(ERROR) << "Unable to initialize logging to " << log_path.value();
41 RemoveSymlinkAndLog(log_path, target_path);
42 } else {
43 chrome_logging_redirected_ = true;
44 }
45 }
46
47 } // namespace logging
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698