Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
Sonde::anonymous_namespace{logeventsource.cpp} Namespace Reference

Classes

struct  HandlerState
 Process-wide state of the message handler. More...
struct  CaptureState
 Process-wide state of LogEventSource::captureCategory(). More...

Functions

HandlerState & state ()
 The process-wide handler state.
bool & inHandler ()
 Set while this thread is inside messageHandler() (recursion guard).
int rank (QtMsgType type)
 Severity rank of a message type: debug 0, info 1, warning 2, critical 3, fatal 4.
CaptureState & capture ()
 The process-wide capture state.
void categoryFilter (QLoggingCategory *category)
 Our category filter: the previous filter decides, then captured categories are turned on.
void applyCaptureFilter ()
 Runs the filter chain again over every category, so a change in what is captured applies.
bool forwardToApplication (QtMsgType type, const char *category)
 Whether a message of type in category should reach the previous handler.
LogLevel levelFor (QtMsgType type)
 Maps a Qt message type to an MCP log level.
Event eventFor (QtMsgType type, const QMessageLogContext &context, const QString &message)
 The event for one log message (without the "thread" field).
QString currentThreadName ()
 The calling thread's objectName, or its id if it has none.
void post (Event e)
 Hands e to the active source, if there is one.
void messageHandler (QtMsgType type, const QMessageLogContext &context, const QString &message)
 The installed Qt message handler: queues an event, then chains to the previous handler.
bool claimInstance (LogEventSource *source)
 Makes source the active instance unless one exists.

Function Documentation

◆ applyCaptureFilter()

void Sonde::anonymous_namespace{logeventsource.cpp}::applyCaptureFilter ( )

Runs the filter chain again over every category, so a change in what is captured applies.

Qt has no call for that, but installing a filter applies it to every existing category. If a filter was installed after ours, it is put back on top (it chains to ours, and installing it applies the whole chain).

◆ claimInstance()

bool Sonde::anonymous_namespace{logeventsource.cpp}::claimInstance ( LogEventSource * source)

Makes source the active instance unless one exists.

Returns
Whether it did.

◆ forwardToApplication()

bool Sonde::anonymous_namespace{logeventsource.cpp}::forwardToApplication ( QtMsgType type,
const char * category )

Whether a message of type in category should reach the previous handler.

Messages of a captured category reach it only at levels the application's own rules enable.

◆ post()

void Sonde::anonymous_namespace{logeventsource.cpp}::post ( Event e)

Hands e to the active source, if there is one.

The handler can run deep inside arbitrary code (including our own transports), so it never re-enters the server: on the source's thread the event is queued; from other threads it is emitted, and the server's receiver only records it and queues the rest (see EventBuffer).