@@ -164,15 +164,53 @@ public void Log_InvalidFormat_DoesNotCaptureEnvelope()
164164 _fixture . Hub . Received ( 0 ) . CaptureEnvelope ( Arg . Any < Envelope > ( ) ) ;
165165 var entry = _fixture . DiagnosticLogger . Entries . Should ( ) . ContainSingle ( ) . Which ;
166166 entry . Level . Should ( ) . Be ( SentryLevel . Error ) ;
167- entry . Message . Should ( ) . Be ( "Template string does not match the provided argument." ) ;
167+ entry . Message . Should ( ) . Be ( "Template string does not match the provided argument. The Log will be dropped. " ) ;
168168 entry . Exception . Should ( ) . BeOfType < FormatException > ( ) ;
169169 entry . Args . Should ( ) . BeEmpty ( ) ;
170170 }
171171
172+ [ Fact ]
173+ public void Log_InvalidConfigureLog_DoesNotCaptureEnvelope ( )
174+ {
175+ _fixture . Options . EnableLogs = true ;
176+ var logger = _fixture . GetSut ( ) ;
177+
178+ logger . LogTrace ( "Template string with arguments: {0}, {1}, {2}, {3}" , [ "string" , true , 1 , 2.2 ] , Throw ) ;
179+
180+ _fixture . Hub . Received ( 0 ) . CaptureEnvelope ( Arg . Any < Envelope > ( ) ) ;
181+ var entry = _fixture . DiagnosticLogger . Entries . Should ( ) . ContainSingle ( ) . Which ;
182+ entry . Level . Should ( ) . Be ( SentryLevel . Error ) ;
183+ entry . Message . Should ( ) . Be ( "The configureLog callback threw an exception. The Log will be dropped." ) ;
184+ entry . Exception . Should ( ) . BeOfType < InvalidOperationException > ( ) ;
185+ entry . Args . Should ( ) . BeEmpty ( ) ;
186+ }
187+
188+ [ Fact ]
189+ public void Log_InvalidBeforeSendLog_DoesNotCaptureEnvelope ( )
190+ {
191+ _fixture . Options . EnableLogs = true ;
192+ _fixture . Options . SetBeforeSendLog ( static ( SentryLog log ) => throw new InvalidOperationException ( ) ) ;
193+ var logger = _fixture . GetSut ( ) ;
194+
195+ logger . LogTrace ( "Template string with arguments: {0}, {1}, {2}, {3}" , [ "string" , true , 1 , 2.2 ] ) ;
196+
197+ _fixture . Hub . Received ( 0 ) . CaptureEnvelope ( Arg . Any < Envelope > ( ) ) ;
198+ var entry = _fixture . DiagnosticLogger . Entries . Should ( ) . ContainSingle ( ) . Which ;
199+ entry . Level . Should ( ) . Be ( SentryLevel . Error ) ;
200+ entry . Message . Should ( ) . Be ( "The BeforeSendLog callback threw an exception. The Log will be dropped." ) ;
201+ entry . Exception . Should ( ) . BeOfType < InvalidOperationException > ( ) ;
202+ entry . Args . Should ( ) . BeEmpty ( ) ;
203+ }
204+
172205 private static void ConfigureLog ( SentryLog log )
173206 {
174207 log . SetAttribute ( "attribute-key" , "attribute-value" ) ;
175208 }
209+
210+ private static void Throw ( SentryLog log )
211+ {
212+ throw new InvalidOperationException ( ) ;
213+ }
176214}
177215
178216file static class AssertionExtensions
0 commit comments