UCILoader 1.1.2
Small C++ library that allows user to connect to a chess engines via UCI protocol.
Loading...
Searching...
No Matches
UCILoader::LoggerTrait Class Referenceabstract

Abstract base class for logger traits that customize logger behavior. More...

#include <Logger.h>

Inherited by WrapperTrait< WrapperClass >.

Public Member Functions

virtual ~LoggerTrait ()=default
 Virtual destructor for proper cleanup of derived classes.
 
virtual std::unique_ptr< LoggeraddTo (std::unique_ptr< Logger > &&logger) const =0
 Apply this trait to a logger by wrapping it.
 

Detailed Description

Abstract base class for logger traits that customize logger behavior.

The LoggerTrait mechanism provides a flexible way to add functionality to loggers using the decorator pattern. Traits can be composed together to apply multiple behaviors to a single logger.

Common use cases:

  • Adding timestamps to log messages (Timestamp trait)
  • Formatting messages for readability (Pretty trait)
  • Filtering messages by direction (IgnoreParser, IgnoreEngine, IgnoreApplication traits)
See also
LoggerBuilder for how to apply traits
LoggerTraits namespace for built-in trait implementations

Example usage with LoggerBuilder:

// Create a file logger with Pretty formatting and timestamps
const LoggerTrait & Timestamp
Trait that prepends timestamps to all logged messages.
Definition: Logger.cpp:169
const LoggerTrait & Pretty
Trait that formats log messages for human readability.
Definition: Logger.cpp:165
LoggerBuilder toFile(const std::string &filename)
Create a logger that outputs to a file.
Definition: Logger.cpp:185

Member Function Documentation

◆ addTo()

virtual std::unique_ptr< Logger > UCILoader::LoggerTrait::addTo ( std::unique_ptr< Logger > &&  logger) const
pure virtual

Apply this trait to a logger by wrapping it.

Implementations should create a wrapper that applies the trait's behavior to the provided logger.

Parameters
loggerThe logger to apply this trait to
Returns
A new logger with this trait applied

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