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
Scopedoperator= (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:171

Definition at line 171 of file EonLogger.h.

Constructor & Destructor Documentation

◆ Scoped()

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

Definition at line 174 of file EonLogger.h.

175 : logger(get()) {}
quill::Logger * get() noexcept
Get or create the default "combi" logger.
Definition EonLogger.h:44
quill::Logger * logger
Definition EonLogger.h:172

Member Function Documentation

◆ operator quill::Logger *()

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

Definition at line 178 of file EonLogger.h.

178{ return logger; }

◆ operator->()

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

Definition at line 181 of file EonLogger.h.

181{ return logger; }

◆ operator=()

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

Definition at line 184 of file EonLogger.h.

184 {
185 logger = l;
186 return *this;
187 }

◆ ptr()

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

Definition at line 190 of file EonLogger.h.

190{ return logger; }

Member Data Documentation

◆ logger

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

Definition at line 172 of file EonLogger.h.

172{nullptr};

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