Commit 2f89e530 authored by Meilin Wang's avatar Meilin Wang Committed by Commit Bot

Add a chromeos swicth to redirect libassistant logging.

This change adds a new chromeos switch "redirect-libassistant-logging"
to control redirect libassistant logging from /home/chronos/user/log to
/var/log/chrome. One scenario to use this switch is in the Tast integration
tests, where we want to export libassistant.log into the test result
package to help debugging test failure. The previous logging directory
/home/chronos/user is an encrypted user home directory, so we need to
move the log to /var/log/chrome where Tast collects newly-written data
after running all tests.

Bug: 950197.
Test: local compile and manually test.
Change-Id: I4f5124d53d1c55f03738b9823c82dc83c3e3580f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1560145
Commit-Queue: Meilin Wang <meilinw@chromium.org>
Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#649249}
parent 0744b2bc
...@@ -488,6 +488,9 @@ const char kOobeTimerInterval[] = "oobe-timer-interval"; ...@@ -488,6 +488,9 @@ const char kOobeTimerInterval[] = "oobe-timer-interval";
// must succeed, otherwise session restart should fail). // must succeed, otherwise session restart should fail).
const char kProfileRequiresPolicy[] = "profile-requires-policy"; const char kProfileRequiresPolicy[] = "profile-requires-policy";
// Redirects libassistant logging to /var/log/chrome/.
const char kRedirectLibassistantLogging[] = "redirect-libassistant-logging";
// The rlz ping delay (in seconds) that overwrites the default value. // The rlz ping delay (in seconds) that overwrites the default value.
const char kRlzPingDelay[] = "rlz-ping-delay"; const char kRlzPingDelay[] = "rlz-ping-delay";
......
...@@ -188,6 +188,8 @@ COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kOobeSkipPostLogin[]; ...@@ -188,6 +188,8 @@ COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kOobeSkipPostLogin[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kOobeSkipToLogin[]; COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kOobeSkipToLogin[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kOobeTimerInterval[]; COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kOobeTimerInterval[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kProfileRequiresPolicy[]; COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kProfileRequiresPolicy[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const char kRedirectLibassistantLogging[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kRegulatoryLabelDir[]; COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kRegulatoryLabelDir[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kRlzPingDelay[]; COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kRlzPingDelay[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kSamlPasswordChangeUrl[]; COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kSamlPasswordChangeUrl[];
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <utility> #include <utility>
#include "base/command_line.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/json/json_writer.h" #include "base/json/json_writer.h"
#include "base/logging.h" #include "base/logging.h"
...@@ -13,6 +14,7 @@ ...@@ -13,6 +14,7 @@
#include "base/system/sys_info.h" #include "base/system/sys_info.h"
#include "base/values.h" #include "base/values.h"
#include "chromeos/assistant/internal/internal_constants.h" #include "chromeos/assistant/internal/internal_constants.h"
#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/dbus/util/version_loader.h" #include "chromeos/dbus/util/version_loader.h"
#include "chromeos/services/assistant/public/features.h" #include "chromeos/services/assistant/public/features.h"
...@@ -52,11 +54,17 @@ std::string CreateLibAssistantConfig() { ...@@ -52,11 +54,17 @@ std::string CreateLibAssistantConfig() {
internal.SetKey("surface_type", Value("OPA_CROS")); internal.SetKey("surface_type", Value("OPA_CROS"));
if (base::SysInfo::IsRunningOnChromeOS()) { if (base::SysInfo::IsRunningOnChromeOS()) {
// Log to 'log' sub dir in user's home dir.
Value logging(Type::DICTIONARY); Value logging(Type::DICTIONARY);
logging.SetKey( // Redirect libassistant logging to /var/log/chrome/ if has the switch,
"directory", // otherwise log to 'log' sub dir in user's home dir.
Value(GetRootPath().Append(FILE_PATH_LITERAL("log")).value())); const bool redirect_logging =
base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kRedirectLibassistantLogging);
const std::string log_dir =
redirect_logging
? "/var/log/chrome/"
: GetRootPath().Append(FILE_PATH_LITERAL("log")).value();
logging.SetKey("directory", Value(log_dir));
// Maximum disk space consumed by all log files. There are 5 rotating log // Maximum disk space consumed by all log files. There are 5 rotating log
// files on disk. // files on disk.
logging.SetKey("max_size_kb", Value(3 * 1024)); logging.SetKey("max_size_kb", Value(3 * 1024));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment