Github user phrocker commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/104#discussion_r118527831
  
    --- Diff: libminifi/test/TestBase.h ---
    @@ -21,35 +21,104 @@
     #include <dirent.h>
     #include <cstdio>
     #include <cstdlib>
    +#include <sstream>
     #include "ResourceClaim.h"
     #include "catch.hpp"
     #include <vector>
    -#include "core/logging/LogAppenders.h"
     #include "core/logging/Logger.h"
     #include "core/Core.h"
     #include "properties/Configure.h"
    +#include "properties/Properties.h"
    +#include "core/logging/LoggerConfiguration.h"
    +#include "spdlog/sinks/ostream_sink.h"
    +#include "spdlog/sinks/dist_sink.h"
     
     class LogTestController {
      public:
    -  LogTestController(const std::string level = "debug") {
    -    logging::Logger::getLogger()->setLogLevel(level);
    +  static LogTestController& getInstance() {
    +   static LogTestController instance;
    +   return instance;
       }
    -
    -  void enableDebug() {
    -    logging::Logger::getLogger()->setLogLevel("debug");
    +  
    +  template<typename T>
    +  void setDebug() {
    +    setLevel<T>(spdlog::level::debug);
    +  }
    +  
    +  template<typename T>
    +  void setInfo() {
    +    setLevel<T>(spdlog::level::info);
    +  }
    +  
    +  template<typename T>
    +  void setLevel(spdlog::level::level_enum level) {
    +    logging::LoggerFactory<T>::getLogger();
    +    std::string name = core::getClassName<T>();
    +    modified_loggers.push_back(name);
    +    setLevel(name, level);
    +  }
    +  
    +  bool contains(const std::string &ending) {
    +   return contains(log_output, ending);
    +  }
    +  
    +  bool contains(const std::ostringstream &stream, const std::string 
&ending) {
    +    std::string str = stream.str();
    +    logger_->log_info("Looking for %s in %s.", ending, str);
    +    return (ending.length() > 0 && str.find(ending) != std::string::npos);
    +  }
    +  
    +  void reset() {
    +    for (auto const & name : modified_loggers) {
    +      setLevel(name, spdlog::level::err);
    +    }
    +    modified_loggers = std::vector<std::string>();
    +    resetStream(log_output);
    +  }
    +  
    +  inline bool resetStream(std::ostringstream &stream) {
    +    stream.str("");
    +    stream.clear();
    --- End diff --
    
    this generates a warning. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to