CppTrail
Loading...
Searching...
No Matches
CppTrail::BasicAsyncOstreamLogger< char_t > Class Template Reference

An asynchronous logger handle that dispatches output to a C++ standard stream. More...

#include <ostream_logger.h>

Inheritance diagram for CppTrail::BasicAsyncOstreamLogger< char_t >:
Collaboration diagram for CppTrail::BasicAsyncOstreamLogger< char_t >:

Public Member Functions

 BasicAsyncOstreamLogger (std::basic_ostream< char_t > &oOstream, const bool bUseLocalTime=true)
 Constructs a AsyncLogger from a raw stream reference.
 
 BasicAsyncOstreamLogger (std::reference_wrapper< std::basic_ostream< char_t > > oOstream, const bool bUseLocalTime=true)
 Constructs a AsyncLogger from a reference_wrapper.
 
 BasicAsyncOstreamLogger (std::reference_wrapper< std::basic_ostream< char_t > > oOstream, const bool bUseLocalTime, std::size_t nMaxEntryCount, bool bThrowOnOverflow)
 Constructs a AsyncLogger from a reference_wrapper.
 
- Public Member Functions inherited from CppTrail::BasicLogger< char_t >
 BasicLogger (nullptr_t)=delete
 Prevents construction from a null pointer.
 
 BasicLogger (const BasicLogger &pLogger)=default
 Copy constructor (defaults to shared ownership).
 
 BasicLogger (BasicLogger &&pLogger)=default
 Move constructor.
 
BasicLoggeroperator= (const BasicLogger &pLogger)=default
 Assignment operator.
 
BasicLoggeroperator= (BasicLogger &&pLogger)=default
 Assignment operator.
 
void start ()
 Starts the underlying logging service.
 
void stop ()
 Performs a synchronous shutdown of the logger.
 
void signalStop ()
 Initiates an asynchronous shutdown request.
 
void join ()
 Blocks until the asynchronous shutdown sequence is complete.
 
Status status ()
 Retrieves the current operational status of the logger.
 
BasicLoggerlog (message_type oMessage)
 Submits a pre-constructed message object to the logger.
 
BasicLoggerlog (const Level nLevel, string_type sMessage)
 Logs a message with a specific severity level.
 
BasicLoggerlog (string_type sLevel, string_type sMessage)
 Logs a message with a custom string-based level.
 
BasicLoggersuccess (string_type sMessage)
 Submits a SUCCESS level log message.
 
BasicLoggertrace (string_type sMessage)
 Submits a TRACE level log message.
 
BasicLoggerdebug (string_type sMessage)
 Submits a DEBUG level log message.
 
BasicLoggerinfo (string_type sMessage)
 Submits an INFO level log message.
 
BasicLoggermessage (string_type sMessage)
 Submits a MESSAGE level log message.
 
BasicLoggerwarning (string_type sMessage)
 Submits a WARNING level log message.
 
BasicLoggererror (string_type sMessage)
 Submits an ERROR level log message.
 
BasicLoggercritical (string_type sMessage)
 Submits a CRITICAL level log message.
 
BasicLoggerfatal (string_type sMessage)
 Submits a FATAL level log message.
 
BasicLoggersuccess (string_view_type sMsg)
 Success wrapper for string views.
 
BasicLoggertrace (string_view_type sMsg)
 Trace wrapper for string views.
 
BasicLoggerdebug (string_view_type sMsg)
 Debug wrapper for string views.
 
BasicLoggerinfo (string_view_type sMsg)
 Info wrapper for string views.
 
BasicLoggermessage (string_view_type sMsg)
 Message wrapper for string views.
 
BasicLoggerwarning (string_view_type sMsg)
 Warning wrapper for string views.
 
BasicLoggererror (string_view_type sMsg)
 Error wrapper for string views.
 
BasicLoggercritical (string_view_type sMsg)
 Critical wrapper for string views.
 
BasicLoggerfatal (string_view_type sMsg)
 Fatal wrapper for string views.
 
BasicLoggersuccess (const char_t *sMsg)
 Success wrapper for string litterals.
 
BasicLoggertrace (const char_t *sMsg)
 Trace wrapper for string litterals.
 
BasicLoggerdebug (const char_t *sMsg)
 Debug wrapper for string litterals.
 
BasicLoggerinfo (const char_t *sMsg)
 Info wrapper for string litterals.
 
BasicLoggermessage (const char_t *sMsg)
 Message wrapper for string litterals.
 
BasicLoggerwarning (const char_t *sMsg)
 Warning wrapper for string litterals.
 
BasicLoggererror (const char_t *sMsg)
 Error wrapper for string litterals.
 
BasicLoggercritical (const char_t *sMsg)
 Critical wrapper for string litterals.
 
BasicLoggerfatal (const char_t *sMsg)
 Fatal wrapper for string litterals.
 
BasicLoggerlog (const Level nLevel, string_view_type sMessage)
 Logs a message view with a specific severity level.
 
BasicLoggerlog (string_type sLevel, string_view_type sMessage)
 Logs a message view with a custom string level.
 
BasicLoggerlog (const Level nLevel, const char_t *sMessage)
 Logs a message view with a specific severity level.
 
BasicLoggerlog (string_type sLevel, const char_t *sMessage)
 Logs a message view with a custom string level.
 
template<typename T = char_t, typename std::enable_if< std::is_same< T, char >::value, int >::type = 0>
BasicLoggerlog (const std::exception &oException)
 Logs an exception with the default ERROR level.
 
template<typename T = char_t, typename std::enable_if< std::is_same< T, char >::value, int >::type = 0>
BasicLoggerlog (const Level nLevel, const std::exception &oException)
 Logs an exception with a specific severity level.
 
template<typename T = char_t, typename std::enable_if< std::is_same< T, char >::value, int >::type = 0>
BasicLoggerlog (string_type sLevel, const std::exception &oException)
 Logs an exception with a custom string level.
 

Additional Inherited Members

- Public Types inherited from CppTrail::BasicLogger< char_t >
using char_type = typename BasicLoggerImpl< char_t >::char_type
 Alias for the underlying character type used by this logger.
 
using string_type = typename BasicLoggerImpl< char_t >::string_type
 Alias for the basic_string type associated with this logger's encoding.
 
using message_type = typename BasicLoggerImpl< char_t >::message_type
 Alias for the BasicMessage type associated to the logger.
 
using string_view_type = typename BasicLoggerImpl< char_t >::string_view_type
 Alias for the basic_string_view type associated with this logger's encoding.
 
- Protected Member Functions inherited from CppTrail::BasicLogger< char_t >
 BasicLogger (std::shared_ptr< BasicLoggerImpl< char_t > > pLogger)
 Protected constructor for derived factories.
 
 ~BasicLogger ()
 Destructor that ensures a graceful shutdown of the logger.
 

Detailed Description

template<typename char_t>
class CppTrail::BasicAsyncOstreamLogger< char_t >

An asynchronous logger handle that dispatches output to a C++ standard stream.

This class provides a non-blocking interface for stream-based logging. Log entries are submitted to an internal thread-safe queue and processed by a background worker thread, ensuring that I/O stalls (e.g., slow terminal scrolling or disk latency) do not block the application's critical path.

Note
This is the asynchronous counterpart to BasicOstreamLogger. It is particularly suited for high-throughput "wire stuff" where logging overhead must be minimized.
Template Parameters
char_tThe character type (e.g., char, wchar_t) used for the stream and log encoding.

Constructor & Destructor Documentation

◆ BasicAsyncOstreamLogger() [1/3]

template<typename char_t >
CppTrail::BasicAsyncOstreamLogger< char_t >::BasicAsyncOstreamLogger ( std::basic_ostream< char_t > &  oOstream,
const bool  bUseLocalTime = true 
)
inline

Constructs a AsyncLogger from a raw stream reference.

Parameters
oOstreamThe output stream to be used for logging.
bUseLocalTimeIf true, uses local time for timestamps; otherwise, uses UTC.

◆ BasicAsyncOstreamLogger() [2/3]

template<typename char_t >
CppTrail::BasicAsyncOstreamLogger< char_t >::BasicAsyncOstreamLogger ( std::reference_wrapper< std::basic_ostream< char_t > >  oOstream,
const bool  bUseLocalTime = true 
)
inline

Constructs a AsyncLogger from a reference_wrapper.

This overload allows for more flexible lifecycle management of the underlying stream.

Parameters
oOstreamA wrapper around the target output stream.
bUseLocalTimeIf true, uses local time for timestamps; otherwise, uses UTC.

◆ BasicAsyncOstreamLogger() [3/3]

template<typename char_t >
CppTrail::BasicAsyncOstreamLogger< char_t >::BasicAsyncOstreamLogger ( std::reference_wrapper< std::basic_ostream< char_t > >  oOstream,
const bool  bUseLocalTime,
std::size_t  nMaxEntryCount,
bool  bThrowOnOverflow 
)
inline

Constructs a AsyncLogger from a reference_wrapper.

This overload allows for more flexible lifecycle management of the underlying stream.

Parameters
oOstreamA wrapper around the target output stream.
bUseLocalTimeIf true, uses local time for timestamps; otherwise, uses UTC.
nMaxEntryCountThe maximum number of log entries allowed in the queue.
bThrowOnOverflowIf true, log() throws LoggerOverflowError when full; otherwise, it drops the log.
Warning
nWorkerCount is dissabled because std::basic_ostream does not offer multi-threading gurarantees That makes the use of multiple workers useless if used mutex is used or jumbled if not.

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