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

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

Issue 2901173002: Move RedirectChromeLogging to src/chromeos. (Closed)
Patch Set: Created 3 years, 7 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 namespace {
15
16 // This should be true for exactly the period between the end of
17 // InitChromeLogging() and the beginning of CleanupChromeLogging().
18 bool chrome_logging_redirected_ = false;
sky 2017/05/25 02:23:56 How about making this local to the function that u
achuithb 2017/05/25 10:06:06 Done.
19
20 } // namespace
21
22 void RedirectChromeLogging(const base::CommandLine& command_line) {
23 if (chrome_logging_redirected_) {
24 // TODO: Support multiple active users. http://crbug.com/230345
25 LOG(WARNING) << "NOT redirecting logging for multi-profiles case.";
26 return;
27 }
28
29 DCHECK(!chrome_logging_redirected_)
30 << "Attempted to redirect logging when it was already initialized.";
31
32 // Redirect logs to the session log directory, if set. Otherwise
33 // defaults to the profile dir.
34 const base::FilePath log_path = GetSessionLogFile(command_line);
35
36 // Always force a new symlink when redirecting.
37 const base::FilePath target_path = SetUpSymlinkIfNeeded(log_path, true);
38
39 // ChromeOS always logs through the symlink, so it shouldn't be
40 // deleted if it already exists.
41 logging::LoggingSettings settings;
42 settings.logging_dest = DetermineLogMode(command_line);
43 settings.log_file = log_path.value().c_str();
44 if (!logging::InitLogging(settings)) {
45 DLOG(ERROR) << "Unable to initialize logging to " << log_path.value();
46 RemoveSymlinkAndLog(log_path, target_path);
47 } else {
48 chrome_logging_redirected_ = true;
49 }
50 }
51
52 } // namespace logging
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698