Function convertTemplateToStdString

Synopsis

#include <src/easylogging++.h>

template <typename T>
static std::string convertTemplateToStdString(const T &templ)

Description

Converts template to std::string - useful for loggable classes to log containers within log(std::ostream&) const.

Source

Lines 3740-3759 in src/easylogging++.h.

template <typename T>
static std::string convertTemplateToStdString(const T& templ) {
  el::Logger* logger =
    ELPP->registeredLoggers()->get(el::base::consts::kDefaultLoggerId);
  if (logger == nullptr) {
    return std::string();
  }
  base::MessageBuilder b;
  b.initialize(logger);
  logger->acquireLock();
  b << templ;
f defined(ELPP_UNICODE)
  std::string s = std::string(logger->stream().str().begin(), logger->stream().str().end());
lse
  std::string s = logger->stream().str();
ndif  // defined(ELPP_UNICODE)
  logger->stream().str(ELPP_LITERAL(""));
  logger->releaseLock();
  return s;
}





Add Discussion

Log in to comment