Loading...
Searching...
No Matches
eonc::log::Scoped Struct Reference

RAII helper for class-scoped logging. More...

#include <EonLogger.h>

Public Member Functions

 Scoped () noexcept
 operator quill::Logger * () const noexcept
quill::Logger * operator-> () const noexcept
Scoped & operator= (quill::Logger *l) noexcept
quill::Logger * ptr () const noexcept

Public Attributes

quill::Logger * logger {nullptr}

Detailed Description

RAII helper for class-scoped logging.

Automatically retrieves the "combi" logger on construction. Designed for member variables: just declare eonc::log::Scoped m_log; and use it.

Example:

class MyClass {
eonc::log::Scoped m_log; // No manual initialization needed!
public:
void work() {
QUILL_LOG_INFO(m_log, "doing work");
}
};
RAII helper for class-scoped logging.
Definition EonLogger.h:238

Definition at line 238 of file EonLogger.h.

Constructor & Destructor Documentation

◆ Scoped()

eonc::log::Scoped::Scoped ( )
inlinenoexcept

Definition at line 241 of file EonLogger.h.

241: logger(get()) {}
quill::Logger * get() noexcept
Get or create the default "combi" logger.
Definition EonLogger.h:111
quill::Logger * logger
Definition EonLogger.h:239

Member Function Documentation

◆ operator quill::Logger *()

eonc::log::Scoped::operator quill::Logger * ( ) const
inlinenoexcept

Definition at line 244 of file EonLogger.h.

244{ return logger; }

◆ operator->()

quill::Logger * eonc::log::Scoped::operator-> ( ) const
inlinenoexcept

Definition at line 247 of file EonLogger.h.

247{ return logger; }

◆ operator=()

Scoped & eonc::log::Scoped::operator= ( quill::Logger * l)
inlinenoexcept

Definition at line 250 of file EonLogger.h.

250 {
251 logger = l;
252 return *this;
253 }

◆ ptr()

quill::Logger * eonc::log::Scoped::ptr ( ) const
inlinenodiscardnoexcept

Definition at line 256 of file EonLogger.h.

256{ return logger; }

Member Data Documentation

◆ logger

quill::Logger* eonc::log::Scoped::logger {nullptr}

Definition at line 239 of file EonLogger.h.

239{nullptr};

The documentation for this struct was generated from the following file: