Skip to content

Commit 71d2d80

Browse files
feat(logs): Clarify API for Hub/Scope and Client (#15281)
Clarify that the Hub/Scope must also offer the same API as the static API, and that the client should only offer one generic method.
1 parent d637dbc commit 71d2d80

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

develop-docs/sdk/telemetry/logs.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ Sentry.logger.warn("User %s performed action %s", [userId, actionName], {
188188
});
189189
```
190190

191-
Aside from accepting attributes, these methods can be overloaded to accept severity number or other parameters if required for the language or platform.
191+
Aside from accepting attributes, these methods can be overloaded to accept severity number or other parameters if required for the language or platform. The Hub/Scope MUST offer the same methods as the static API `Sentry.logger.X`, which is useful for power users who want to use multiple Hubs/Scopes. The Client SHOULD only offer one generic method that accepts the log object and the Scope, such as `captureLog(log, scope)`.
192192

193193
Beyond the specified methods, SDKs are free to add any extra helpers as they feel is necessary. For example, they could choose to add specialized decorators or helpers for string template creation.
194194

@@ -255,6 +255,8 @@ In general log processing should follow this order:
255255

256256
1. Capture log via [Public APIs](#logger-module) (e.g. `Sentry.logger.info`) or via [SDK integrations](#sdk-integrations).
257257
1. Check if logging is enabled as per `enableLogs`/`enable_logs` configuration - if not, skip the rest of the steps.
258+
1. Pass the log to Hub/Scope, which MUST offer the same methods as the static API `Sentry.logger.X`. This is useful for power users who want to use multiple Hubs/Scopes.
259+
1. Pass the log to the Client, via a generic method that accepts the log object and the `scope`, such as `captureLog(log, scope)`.
258260
1. Process captured log (attach attributes as per [default attributes](#default-attributes)).
259261
1. Run `beforeSendLog`/`before_send_log` to filter or modify the log.
260262
1. Add log to buffer/batch processor as detailed in [buffering](#buffering).

0 commit comments

Comments
 (0)