Log sends a log message to the client. The message is not sent if the client has not called SetLevel, or if its level is below that of the last SetLevel.
(ctx context.Context, params *LoggingMessageParams)
| 1310 | // The message is not sent if the client has not called SetLevel, or if its level |
| 1311 | // is below that of the last SetLevel. |
| 1312 | func (ss *ServerSession) Log(ctx context.Context, params *LoggingMessageParams) error { |
| 1313 | ss.mu.Lock() |
| 1314 | logLevel := ss.state.LogLevel |
| 1315 | ss.mu.Unlock() |
| 1316 | if logLevel == "" { |
| 1317 | // The spec is unclear, but seems to imply that no log messages are sent until the client |
| 1318 | // sets the level. |
| 1319 | // TODO(jba): read other SDKs, possibly file an issue. |
| 1320 | return nil |
| 1321 | } |
| 1322 | if compareLevels(params.Level, logLevel) < 0 { |
| 1323 | return nil |
| 1324 | } |
| 1325 | return handleNotify(ctx, notificationLoggingMessage, newServerRequest(ss, orZero[Params](params))) |
| 1326 | } |
| 1327 | |
| 1328 | // AddSendingMiddleware wraps the current sending method handler using the provided |
| 1329 | // middleware. Middleware is applied from right to left, so that the first one is |