LogCategoryConfig.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright 2017-present Facebook, Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #pragma once
  17. #include <string>
  18. #include <vector>
  19. #include <folly/Optional.h>
  20. #include <folly/logging/LogLevel.h>
  21. namespace folly {
  22. /**
  23. * Configuration for a LogCategory
  24. */
  25. class LogCategoryConfig {
  26. public:
  27. explicit LogCategoryConfig(
  28. LogLevel level = kDefaultLogLevel,
  29. bool inheritParentLevel = true);
  30. LogCategoryConfig(
  31. LogLevel level,
  32. bool inheritParentLevel,
  33. std::vector<std::string> handlers);
  34. bool operator==(const LogCategoryConfig& other) const;
  35. bool operator!=(const LogCategoryConfig& other) const;
  36. /**
  37. * The LogLevel for this category.
  38. */
  39. LogLevel level{kDefaultLogLevel};
  40. /**
  41. * Whether this category should inherit its effective log level from its
  42. * parent category, if the parent category has a more verbose log level.
  43. */
  44. bool inheritParentLevel{true};
  45. /**
  46. * An optional list of LogHandler names to use for this category.
  47. *
  48. * When applying config changes to an existing LogCategory, the existing
  49. * LogHandler list will be left unchanged if this field is unset.
  50. */
  51. Optional<std::vector<std::string>> handlers;
  52. };
  53. } // namespace folly