|
16 | 16 | import io.sentry.InitPriority; |
17 | 17 | import io.sentry.ScopesAdapter; |
18 | 18 | import io.sentry.Sentry; |
| 19 | +import io.sentry.SentryAttribute; |
| 20 | +import io.sentry.SentryAttributes; |
19 | 21 | import io.sentry.SentryEvent; |
20 | 22 | import io.sentry.SentryIntegrationPackageStorage; |
21 | 23 | import io.sentry.SentryLevel; |
22 | 24 | import io.sentry.SentryLogLevel; |
23 | 25 | import io.sentry.SentryOptions; |
24 | 26 | import io.sentry.exception.ExceptionMechanismException; |
| 27 | +import io.sentry.logger.SentryLogParameters; |
25 | 28 | import io.sentry.protocol.Mechanism; |
26 | 29 | import io.sentry.protocol.Message; |
27 | 30 | import io.sentry.protocol.SdkVersion; |
@@ -177,14 +180,20 @@ protected void append(@NotNull ILoggingEvent eventObject) { |
177 | 180 | protected void captureLog(@NotNull ILoggingEvent loggingEvent) { |
178 | 181 | final @NotNull SentryLogLevel sentryLevel = toSentryLogLevel(loggingEvent.getLevel()); |
179 | 182 |
|
180 | | - // // if encoder is set we treat message+params as PII as encoders may be used to mask/strip |
181 | | - // PII |
182 | | - // if (encoder == null || options.isSendDefaultPii()) { |
183 | | - // message.setMessage(loggingEvent.getMessage()); |
184 | | - // message.setParams(toParams(loggingEvent.getArgumentArray())); |
185 | | - // } |
| 183 | + @Nullable Object[] arguments = null; |
| 184 | + final @NotNull SentryAttributes attributes = SentryAttributes.of(); |
186 | 185 |
|
187 | | - Sentry.logger().log(sentryLevel, formatted(loggingEvent), loggingEvent.getArgumentArray()); |
| 186 | + // if encoder is set we treat message+params as PII as encoders may be used to mask/strip PII |
| 187 | + if (encoder == null || options.isSendDefaultPii()) { |
| 188 | + attributes.add( |
| 189 | + SentryAttribute.stringAttribute("sentry.message.template", loggingEvent.getMessage())); |
| 190 | + arguments = loggingEvent.getArgumentArray(); |
| 191 | + } |
| 192 | + |
| 193 | + final @NotNull String formattedMessage = formatted(loggingEvent); |
| 194 | + final @NotNull SentryLogParameters params = SentryLogParameters.create(attributes); |
| 195 | + |
| 196 | + Sentry.logger().log(sentryLevel, params, formattedMessage, arguments); |
188 | 197 | } |
189 | 198 |
|
190 | 199 | private String formatted(@NotNull ILoggingEvent loggingEvent) { |
|
0 commit comments