|
CppTrail
|
A synchronous, thread-safe logger implementation template. This class ensures that every log call is processed immediately on the calling thread. Access to the 'work' function is protected by a mutex, making it safe for multi-threaded environments, though it may introduce latency in the calling thread. More...
#include <sync_logger.h>


Public Types | |
| 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. | |
Public Types inherited from CppTrail::BasicLoggerImpl< char_t > | |
| using | char_type = char_t |
| Alias for the underlying character type used by this logger. | |
| using | string_type = std::basic_string< char_type > |
| Alias for the basic_string type associated with this logger's encoding. | |
| using | message_type = BasicMessage< char_type > |
| Alias for the BasicMessage type associated to the logger. | |
| using | string_view_type = std::basic_string_view< char_type > |
| Alias for the basic_string_view type associated with this logger's encoding. | |
Public Member Functions | |
| void | log (message_type oMessage) final |
| Synchronously processes and records a log message. | |
| void | start () final |
| Starts the logger service. | |
| void | stop () final |
| Stops the logger service. | |
| void | signalStop () final |
| Signals the logger to stop. | |
| void | join () override |
| Waits for the asynchronous end of the shutdown sequence. | |
| Status | status () final |
| Retrieves the current status of the service. | |
Public Member Functions inherited from CppTrail::BasicLoggerImpl< char_t > | |
| virtual | ~BasicLoggerImpl ()=default |
| Virtual destructor to ensure proper cleanup of derived logger resources. | |
Protected Member Functions | |
| ~BasicSyncLoggerImpl () override=default | |
| Destructor. | |
| virtual void | work (message_type oMessage)=0 |
| Abstract method where the actual logging I/O occurs. | |
Internal Service Interface | |
These methods must be implemented by derived classes to handle the specific backend lifecycle without worrying about locking. | |
| virtual Status | serviceStatus ()=0 |
| Non-locking call to get the current service status. | |
| virtual void | serviceStart ()=0 |
| Non-locking call to initiate service startup. | |
| virtual void | serviceStop ()=0 |
| Non-locking call to initiate service shutdown. | |
A synchronous, thread-safe logger implementation template. This class ensures that every log call is processed immediately on the calling thread. Access to the 'work' function is protected by a mutex, making it safe for multi-threaded environments, though it may introduce latency in the calling thread.
| char_t | The character type (e.g., char, char8_t) used for the log content. |
|
overrideprotecteddefault |
Destructor.
|
inlineoverridevirtual |
Waits for the asynchronous end of the shutdown sequence.
This function is used in conjunction with signalStop() to ensure description safety.
Implements CppTrail::BasicLoggerImpl< char_t >.
|
inlinefinalvirtual |
Synchronously processes and records a log message.
This method is the primary entry point for synchronous logging. It performs a thread-safe check of the service status before invoking the internal work() method.
| oMessage | The message implementation to be recorded. This object is moved into the processing pipeline to avoid unnecessary copies. |
Implements CppTrail::BasicLoggerImpl< char_t >.
|
inlinefinalvirtual |
Signals the logger to stop.
For synchronous loggers, this is functionally equivalent to stop() as there is no background queue to drain.
Implements CppTrail::BasicLoggerImpl< char_t >.
|
inlinefinalvirtual |
Starts the logger service.
Blocks until the internal serviceStart() completes and the status is RUNNING.
Implements CppTrail::BasicLoggerImpl< char_t >.
|
inlinefinalvirtual |
Retrieves the current status of the service.
Implements CppTrail::BasicLoggerImpl< char_t >.
|
inlinefinalvirtual |
Stops the logger service.
Blocks until the internal serviceStop() completes and the status is STOPPED.
Implements CppTrail::BasicLoggerImpl< char_t >.
|
protectedpure virtual |
Abstract method where the actual logging I/O occurs.
This is called while the general mutex is held.
| oMessage | The message to be recorded. |