您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

41 行
1.0 KiB

  1. #include <cpputils/logging/matcher.h>
  2. using namespace ::utl::logging;
  3. /* matcher */
  4. bool matcher::match(const logger& logger) const
  5. { return false; }
  6. bool matcher::match(const consumer& consumer) const
  7. { return false; }
  8. /* matcher_all */
  9. bool matcher_all::match(const logger& logger) const
  10. { return true; }
  11. bool matcher_all::match(const consumer& consumer) const
  12. { return true; }
  13. /* matcher_regex */
  14. bool matcher_regex::match(const logger& logger) const
  15. { return !logger.name().empty() && std::regex_match(logger.name(), _regex) != _invert; }
  16. bool matcher_regex::match(const consumer& consumer) const
  17. { return !consumer.name().empty() && std::regex_match(consumer.name(), _regex) != _invert; }
  18. matcher_regex::matcher_regex(const std::string expression, bool invert) :
  19. _regex (expression),
  20. _invert (invert)
  21. { }
  22. /* matcher_default */
  23. bool matcher_default::match(const logger& logger) const
  24. { return &_defaultLogger == &logger; }
  25. matcher_default::matcher_default() :
  26. _defaultLogger(get_logger(std::string()))
  27. { }