scoped_logging_settings.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2020 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. #ifndef BASE_TEST_SCOPED_LOGGING_SETTINGS_H_
  5. #define BASE_TEST_SCOPED_LOGGING_SETTINGS_H_
  6. #include "base/logging.h"
  7. namespace logging {
  8. // Saves the current logging settings and restores them when destroyed.
  9. // This is used by logging tests to avoid affecting later tests that
  10. // may run afterward, in the same process.
  11. // Note that the log_file setting is not currently saved/restored.
  12. class BASE_EXPORT ScopedLoggingSettings {
  13. public:
  14. ScopedLoggingSettings();
  15. ~ScopedLoggingSettings();
  16. ScopedLoggingSettings(const ScopedLoggingSettings&) = delete;
  17. ScopedLoggingSettings& operator=(const ScopedLoggingSettings&) = delete;
  18. #if defined(OS_CHROMEOS)
  19. void SetLogFormat(LogFormat) const;
  20. #endif
  21. private:
  22. bool enable_process_id_;
  23. bool enable_thread_id_;
  24. bool enable_timestamp_;
  25. bool enable_tickcount_;
  26. int min_log_level_;
  27. LogMessageHandlerFunction message_handler_;
  28. #if defined(OS_CHROMEOS)
  29. LogFormat log_format_;
  30. #endif // defined(OS_CHROMEOS)
  31. };
  32. } // namespace logging
  33. #endif // BASE_TEST_SCOPED_LOGGING_SETTINGS_H_