| 1 | // Copyright 2013 The Flutter 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 | #ifndef FLUTTER_FML_LOG_SETTINGS_H_ |
| 6 | #define FLUTTER_FML_LOG_SETTINGS_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include "flutter/fml/log_level.h" |
| 11 | |
| 12 | namespace fml { |
| 13 | |
| 14 | // Settings which control the behavior of FML logging. |
| 15 | struct LogSettings { |
| 16 | // The minimum logging level. |
| 17 | // Anything at or above this level will be logged (if applicable). |
| 18 | // Anything below this level will be silently ignored. |
| 19 | // |
| 20 | // The log level defaults to 0 (LOG_INFO). |
| 21 | // |
| 22 | // Log messages for FML_VLOG(x) (from flutter/fml/logging.h) are logged |
| 23 | // at level -x, so setting the min log level to negative values enables |
| 24 | // verbose logging. |
| 25 | LogSeverity min_log_level = LOG_INFO; |
| 26 | }; |
| 27 | |
| 28 | // Gets the active log settings for the current process. |
| 29 | void SetLogSettings(const LogSettings& settings); |
| 30 | |
| 31 | // Sets the active log settings for the current process. |
| 32 | LogSettings GetLogSettings(); |
| 33 | |
| 34 | // Gets the minimum log level for the current process. Never returs a value |
| 35 | // higher than LOG_FATAL. |
| 36 | int GetMinLogLevel(); |
| 37 | |
| 38 | class ScopedSetLogSettings { |
| 39 | public: |
| 40 | explicit ScopedSetLogSettings(const LogSettings& settings); |
| 41 | ~ScopedSetLogSettings(); |
| 42 | |
| 43 | private: |
| 44 | LogSettings old_settings_; |
| 45 | }; |
| 46 | |
| 47 | } // namespace fml |
| 48 | |
| 49 | #endif // FLUTTER_FML_LOG_SETTINGS_H_ |
| 50 | |