protected EventBuilder createEventBuilder ( LogRecord record ) { EventBuilder eventBuilder = new EventBuilder ( ) . withSdkIntegration ( "java.util.logging" ) . withLevel ( getLevel ( record . getLevel ( ) ) ) . withTimestamp ( new Date ( record . getMillis ( ) ) ) . withLogger ( record . getLoggerName ( ) ) ; String message = record . getMessage ( ) ; if ( record . getResourceBundle ( ) != null && record . getResourceBundle ( ) . containsKey ( record . getMessage ( ) ) ) { message = record . getResourceBundle ( ) . getString ( record . getMessage ( ) ) ; } String topLevelMessage = message ; if ( record . getParameters ( ) == null ) { eventBuilder . withSentryInterface ( new MessageInterface ( message ) ) ; } else { String formatted ; List < String > parameters = formatMessageParameters ( record . getParameters ( ) ) ; try { formatted = formatMessage ( message , record . getParameters ( ) ) ; topLevelMessage = formatted ; // write out formatted as Event's message key } catch ( Exception e ) { // local formatting failed, send message and parameters without formatted string formatted = null ; } eventBuilder . withSentryInterface ( new MessageInterface ( message , parameters , formatted ) ) ; } eventBuilder . withMessage ( topLevelMessage ) ; Throwable throwable = record . getThrown ( ) ; if ( throwable != null ) { eventBuilder . withSentryInterface ( new ExceptionInterface ( throwable ) ) ; } Map < String , String > mdc = MDC . getMDCAdapter ( ) . getCopyOfContextMap ( ) ; if ( mdc != null ) { for ( Map . Entry < String , String > mdcEntry : mdc . entrySet ( ) ) { if ( Sentry . getStoredClient ( ) . getMdcTags ( ) . contains ( mdcEntry . getKey ( ) ) ) { eventBuilder . withTag ( mdcEntry . getKey ( ) , mdcEntry . getValue ( ) ) ; } else { eventBuilder . withExtra ( mdcEntry . getKey ( ) , mdcEntry . getValue ( ) ) ; } } } eventBuilder . withExtra ( THREAD_ID , record . getThreadID ( ) ) ; return eventBuilder ; }
Builds an EventBuilder based on the log record .