File tree Expand file tree Collapse file tree
test/kotlin/io/sentry/jul Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -154,16 +154,9 @@ protected void captureLog(@NotNull LogRecord loggingEvent) {
154154 message = loggingEvent .getResourceBundle ().getString (loggingEvent .getMessage ());
155155 }
156156
157- String formattedMessage = null ;
158- boolean formattingFailed = false ;
159- try {
160- formattedMessage = maybeFormatted (arguments , message );
161- } catch (RuntimeException e ) {
162- formattedMessage = message ;
163- formattingFailed = true ;
164- }
157+ final @ NotNull String formattedMessage = maybeFormatted (arguments , message );
165158
166- if (formattingFailed || !formattedMessage .equals (message )) {
159+ if (!formattedMessage .equals (message )) {
167160 attributes .add (SentryAttribute .stringAttribute ("sentry.message.template" , message ));
168161 }
169162
@@ -180,7 +173,6 @@ protected void captureLog(@NotNull LogRecord loggingEvent) {
180173 return formatMessage (message , arguments );
181174 } catch (RuntimeException e ) {
182175 // local formatting failed, sending raw message instead of formatted message
183- throw e ;
184176 }
185177 }
186178
Original file line number Diff line number Diff line change @@ -555,22 +555,4 @@ class SentryHandlerTest {
555555 }
556556 )
557557 }
558-
559- @Test
560- fun `sets template on log when logging message with parameters and formatting fails due to 0 args` () {
561- fixture = Fixture (minimumLevel = Level .SEVERE , printfStyle = true )
562- fixture.logger.log(Level .SEVERE , " testing message %d" , emptyArray())
563-
564- Sentry .flush(1000 )
565-
566- verify(fixture.transport)
567- .send(
568- checkLogs { logs ->
569- val log = logs.items.first()
570- assertEquals(" testing message %d" , log.body)
571- assertEquals(" testing message %d" , log.attributes?.get(" sentry.message.template" )?.value)
572- assertNull(log.attributes?.get(" sentry.message.parameter.0" ))
573- }
574- )
575- }
576558}
You can’t perform that action at this time.
0 commit comments