Class RegisteredLoggers

Synopsis

#include <src/easylogging++.h>

class RegisteredLoggers : public base::utils::Registry<Logger, std::string>

Description

Loggers repository.

Inheritance

Ancestors: Registry

Methods

RegisteredLoggersRegisteredLoggers.
~RegisteredLoggers
defaultConfigurations
flushAll
get
has
installLoggerRegistrationCallback
loggerRegistrationCallback
logStreamsReference
remove
setDefaultConfigurations
setDefaultLogBuilder
uninstallLoggerRegistrationCallback
unregister

Source

Lines 2351-2419 in src/easylogging++.h.

class RegisteredLoggers : public base::utils::Registry<Logger, std::string> {
 public:
  explicit RegisteredLoggers(const LogBuilderPtr& defaultLogBuilder);

  virtual ~RegisteredLoggers(void) {
    unsafeFlushAll();
  }

  inline void setDefaultConfigurations(const Configurations& configurations) {
    base::threading::ScopedLock scopedLock(lock());
    m_defaultConfigurations.setFromBase(const_cast<Configurations*>(&configurations));
  }

  inline Configurations* defaultConfigurations(void) {
    return &m_defaultConfigurations;
  }

  Logger* get(const std::string& id, bool forceCreation = true);

  template <typename T>
  inline bool installLoggerRegistrationCallback(const std::string& id) {
    return base::utils::Utils::installCallback<T, base::type::LoggerRegistrationCallbackPtr>(id,
           &m_loggerRegistrationCallbacks);
  }

  template <typename T>
  inline void uninstallLoggerRegistrationCallback(const std::string& id) {
    base::utils::Utils::uninstallCallback<T, base::type::LoggerRegistrationCallbackPtr>(id, &m_loggerRegistrationCallbacks);
  }

  template <typename T>
  inline T* loggerRegistrationCallback(const std::string& id) {
    return base::utils::Utils::callback<T, base::type::LoggerRegistrationCallbackPtr>(id, &m_loggerRegistrationCallbacks);
  }

  bool remove(const std::string& id);

  inline bool has(const std::string& id) {
    return get(id, false) != nullptr;
  }

  inline void unregister(Logger*& logger) {
    base::threading::ScopedLock scopedLock(lock());
    base::utils::Registry<Logger, std::string>::unregister(logger->id());
  }

  inline LogStreamsReferenceMapPtr logStreamsReference(void) {
    return m_logStreamsReference;
  }

  inline void flushAll(void) {
    base::threading::ScopedLock scopedLock(lock());
    unsafeFlushAll();
  }

  inline void setDefaultLogBuilder(LogBuilderPtr& logBuilderPtr) {
    base::threading::ScopedLock scopedLock(lock());
    m_defaultLogBuilder = logBuilderPtr;
  }

 private:
  LogBuilderPtr m_defaultLogBuilder;
  Configurations m_defaultConfigurations;
  base::LogStreamsReferenceMapPtr m_logStreamsReference = nullptr;
  std::unordered_map<std::string, base::type::LoggerRegistrationCallbackPtr> m_loggerRegistrationCallbacks;
  friend class el::base::Storage;

  void unsafeFlushAll(void);
};





Add Discussion

Log in to comment