// Copyright 2020 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef BASE_TEST_SCOPED_LOGGING_SETTINGS_H_ #define BASE_TEST_SCOPED_LOGGING_SETTINGS_H_ #include "base/base_export.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/memory/raw_ptr.h" #include "build/chromeos_buildflags.h" namespace logging { class VlogInfo; // Saves the current logging settings and restores them when destroyed. // This is used by logging tests to avoid affecting later tests that // may run afterward, in the same process. // Note that this helper cannot be used when an un-named log-file is configured // via |LoggingSettings::log_file|. class BASE_EXPORT ScopedLoggingSettings { … }; // Replaces the existing VLOG config with a new one based on it // but with extra modules enabled. // // *** Using this leaks memory *** // // For thread safety, we cannot delete the VlogInfo object created by this. // // This is intended for use in testing only, e.g. in the setup of a test, enable // vlogging for modules that are of interest. This can help debug a flaky test // which cannot be reproduced locally while avoiding log-spam from the rest of // the code. // // This follows the same pattern as ScopedFeatureList, with init separate from // construction to allow easy use in test classes. // // Using this on multiple threads requires coordination, ScopedVmoduleSwitches // must be destroyed in reverse creation order. class BASE_EXPORT ScopedVmoduleSwitches { … }; } // namespace logging #endif // BASE_TEST_SCOPED_LOGGING_SETTINGS_H_