accelerometer: initialization logging throttle in AccelerometerFileReader
As we may retry up to 50 times of the initialization in AccelerometerFileReader, this commit shows only the first log of empty directory of /dev/cros-ec-accel and missing Accelerometer trigger. BUG=none TEST=run on octopus Change-Id: Idac9846b1c022ca4658f73b218f68900f4f633d1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2569501 Reviewed-by: Xiaoqian Dai <xdai@chromium.org> Commit-Queue: Cheng-Hao Yang <chenghaoyang@chromium.org> Cr-Commit-Position: refs/heads/master@{#834117}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
fc663d026f
commit
c91ec73843
@ -184,12 +184,19 @@ void AccelerometerFileReader::InitializeInternal() {
|
||||
DCHECK(base::SequencedTaskRunnerHandle::IsSet());
|
||||
DCHECK_EQ(State::INITIALIZING, initialization_state_);
|
||||
|
||||
// Log the warning/error messages only in the first initialization to prevent
|
||||
// spamming during the retries of initialization.
|
||||
static bool first_initialization_ = true;
|
||||
|
||||
// Check for accelerometer symlink which will be created by the udev rules
|
||||
// file on detecting the device.
|
||||
if (base::IsDirectoryEmpty(base::FilePath(kAccelerometerDevicePath))) {
|
||||
if (base::SysInfo::IsRunningOnChromeOS()) {
|
||||
LOG(WARNING) << "Accelerometer device directory is empty at "
|
||||
<< kAccelerometerDevicePath;
|
||||
if (first_initialization_) {
|
||||
LOG(WARNING) << "Accelerometer device directory is empty at "
|
||||
<< kAccelerometerDevicePath;
|
||||
}
|
||||
first_initialization_ = false;
|
||||
TryScheduleInitializeInternal();
|
||||
} else {
|
||||
initialization_state_ = State::FAILED;
|
||||
@ -236,7 +243,9 @@ void AccelerometerFileReader::InitializeInternal() {
|
||||
}
|
||||
if (configuration_.trigger_now.empty()) {
|
||||
if (base::SysInfo::IsRunningOnChromeOS()) {
|
||||
LOG(ERROR) << "Accelerometer trigger not found";
|
||||
if (first_initialization_)
|
||||
LOG(ERROR) << "Accelerometer trigger not found";
|
||||
first_initialization_ = false;
|
||||
TryScheduleInitializeInternal();
|
||||
} else {
|
||||
initialization_state_ = State::FAILED;
|
||||
|
Reference in New Issue
Block a user