事件级别

事件级别类似于日志级别,默认情况下通常由 SDK 添加。您也可以在事件中覆盖它。

事件级别类似于日志级别,默认情况下通常由 SDK 添加。您可以在 captureMessage 中直接提供一个专用级别,或者在作用域中配置级别以应用于所有事件。

要设置作用域外的级别,您可以为每个事件调用 captureMessage()

Copied
Sentry.captureMessage("this is a debug message", "debug");

可用的级别有 "fatal""error""warning""log""info""debug"

要设置作用域内的级别,您可以调用 setLevel()

Copied
Sentry.getCurrentScope().setLevel("warning");

或针对每个事件:

Copied
Sentry.withScope(function (scope) {
  scope.setLevel("info");

  // The exception has the event level set by the scope (info).
  Sentry.captureException(new Error("custom error"));
});

// Outside of withScope, the Event level will have their previous value restored.
// The exception has the event level set (error).
Sentry.captureException(new Error("custom error 2"));