![]() |
OpenMS
|
Sink-side hook that is notified whenever a LogStream flushes a complete message. More...
#include <OpenMS/CONCEPT/LogStream.h>
Public Member Functions | |
| LogStreamNotifier () | |
Construct a detached notifier; registered_at_ starts at nullptr. | |
| virtual | ~LogStreamNotifier () |
| Destructor; calls unregister so the LogStream stops dispatching to this notifier. | |
| virtual void | logNotify () |
| Hook called by the registered LogStream after each complete message has been flushed. | |
| void | registerAt (LogStream &log_stream) |
Attach this notifier to log_stream so its logNotify is invoked after every flushed message. | |
| void | unregister () |
| Detach from the currently registered LogStream, if any. | |
Protected Attributes | |
| std::stringstream | stream_ |
| Buffer that receives the formatted log line from the registered LogStream; read inside logNotify. | |
| LogStream * | registered_at_ |
The LogStream this notifier is currently attached to, or nullptr if detached. Managed by registerAt / unregister. | |
Sink-side hook that is notified whenever a LogStream flushes a complete message.
Subclass this and override logNotify to react to log events programmatically. Register the notifier at a LogStream via registerAt — the log stream then treats the notifier's internal stream_ as one of its output sinks, writes each flushed line into it, and invokes the override at the end of every message. Use stream_ inside logNotify to read the formatted message body.
Lifecycle: unregister is called automatically by the destructor (RAII); calling registerAt while already registered first detaches from the previous stream.
Construct a detached notifier; registered_at_ starts at nullptr.
|
virtual |
Destructor; calls unregister so the LogStream stops dispatching to this notifier.
|
virtual |
| void registerAt | ( | LogStream & | log_stream | ) |
Attach this notifier to log_stream so its logNotify is invoked after every flushed message.
If this notifier is already registered at another stream, the prior registration is released first (via unregister). After the call, the stream_ buffer is added to log_stream's output list and tagged as the notification target.
| [in,out] | log_stream | LogStream that will dispatch notifications to this notifier. |
| void unregister | ( | ) |
|
protected |
The LogStream this notifier is currently attached to, or nullptr if detached. Managed by registerAt / unregister.