OpenEnroth 73e68f7
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
LogCategory Class Reference

#include <LogCategory.h>

Public Member Functions

 LogCategory (std::string_view name, LogSource *source=nullptr)
 
 ~LogCategory ()
 
 LogCategory (const LogCategory &)=delete
 
 LogCategory (LogCategory &&)=default
 
std::string_view name () const
 
LogSourcesource () const
 

Static Public Member Functions

static std::vector< LogCategory * > instances ()
 

Private Attributes

std::string_view _name
 
LogSource_source = nullptr
 
std::optional< LogLevel_level
 
std::optional< int > _adjustedLevel
 

Friends

class Logger
 

Detailed Description

Log category, usually used to differentiate logging calls from different subsystems.

Intended usage is to just create a static instance in a .cpp file, and use it when logging.

Log category can be associated with a LogSource, which will then be used when changing per-category log levels.

Constructor & Destructor Documentation

◆ LogCategory() [1/3]

LogCategory::LogCategory ( std::string_view  name,
LogSource source = nullptr 
)
explicit

Creates and registers a new log category instance.

Parameters
nameName of the log category. LogCategory doesn't copy the provided string, so the user is expected to pass a string constant. Different LogCategory instances are expected to have different names, and the constructor will assert if this is not satisfied.
sourceLog source, if any. LogCategory doesn't take ownership of the provided LogSource, and thus lifetime management is up to the user. The best practice is to create both the LogSource and LogCategory as global variables.

◆ ~LogCategory()

LogCategory::~LogCategory ( )

◆ LogCategory() [2/3]

LogCategory::LogCategory ( const LogCategory )
delete

◆ LogCategory() [3/3]

LogCategory::LogCategory ( LogCategory &&  )
default

Member Function Documentation

◆ instances()

std::vector< LogCategory * > LogCategory::instances ( )
static

◆ name()

std::string_view LogCategory::name ( ) const
inline

◆ source()

LogSource * LogCategory::source ( ) const
inline

Friends And Related Function Documentation

◆ Logger

friend class Logger
friend

Member Data Documentation

◆ _adjustedLevel

std::optional<int> LogCategory::_adjustedLevel
private

◆ _level

std::optional<LogLevel> LogCategory::_level
private

◆ _name

std::string_view LogCategory::_name
private

◆ _source

LogSource* LogCategory::_source = nullptr
private

The documentation for this class was generated from the following files: