LogHandlerConfig.h 1.8 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 <unordered_map>
  19. #include <folly/Optional.h>
  20. #include <folly/Range.h>
  21. namespace folly {
  22. /**
  23. * Configuration for a LogHandler
  24. */
  25. class LogHandlerConfig {
  26. public:
  27. using Options = std::unordered_map<std::string, std::string>;
  28. LogHandlerConfig();
  29. explicit LogHandlerConfig(StringPiece type);
  30. explicit LogHandlerConfig(Optional<StringPiece> type);
  31. LogHandlerConfig(StringPiece type, Options options);
  32. LogHandlerConfig(Optional<StringPiece> type, Options options);
  33. /**
  34. * Update this LogHandlerConfig object by merging in settings from another
  35. * LogConfig.
  36. *
  37. * The other LogHandlerConfig must not have a type set.
  38. */
  39. void update(const LogHandlerConfig& other);
  40. bool operator==(const LogHandlerConfig& other) const;
  41. bool operator!=(const LogHandlerConfig& other) const;
  42. /**
  43. * The handler type name.
  44. *
  45. * If this field is unset than this configuration object is intended to be
  46. * used to update an existing LogHandler object. This field must always
  47. * be set in the configuration for all existing LogHandler objects.
  48. */
  49. Optional<std::string> type;
  50. Options options;
  51. };
  52. } // namespace folly