easyloggingpp icon indicating copy to clipboard operation
easyloggingpp copied to clipboard

VLOG_EVERY_N is not using all dispatchers

Open rolandjitsu opened this issue 6 years ago • 0 comments

I've created a custom network dispatcher following the example from this repo and then I configure logging using the following:

#include "utils/easylogging++.h"
#include "utils/net-dispatcher.h"

INITIALIZE_EASYLOGGINGPP

int main(int argc, char* argv[]) {
  START_EASYLOGGINGPP(argc, argv);

  el::Loggers::addFlag(el::LoggingFlag::MultiLoggerSupport);
  el::Helpers::installLogDispatchCallback<NetworkDispatcher>(NETWORK_LOGGER);
  NetworkDispatcher* dispatcher = el::Helpers::logDispatchCallback<NetworkDispatcher>(NETWORK_LOGGER);
  dispatcher->setEnabled(true);
  dispatcher->connect("127.0.0.1", 5000);
  el::Loggers::getLogger(NETWORK_LOGGER);
  el::Configurations defaultConf;
  defaultConf.setToDefault();
  defaultConf.setGlobally(el::ConfigurationType::Format, "{ \"datetime\":\"%datetime\" %msg }");
  el::Loggers::reconfigureLogger("default", defaultConf);
  el::Loggers::reconfigureLogger(NETWORK_LOGGER, defaultConf);
  
  // Works
  LOG(INFO) << "test 1";
  
  // Does not work 
  LOG(WARNING) << "test 2"

  return 0;
}

But it seems like besides LOG(), none of the other macros seem to use the network dispatcher.

rolandjitsu avatar May 15 '19 10:05 rolandjitsu