Object [ ] getObjects ( ExtendedLogEntry logEntry , boolean translatedMsg ) { ArrayList < Object > list = new ArrayList < Object > ( 5 ) ; if ( translatedMsg && logEntry . getMessage ( ) != null ) { list . add ( logEntry . getMessage ( ) ) ; } if ( ! translatedMsg ) { String loggerName = logEntry . getLoggerName ( ) ; if ( loggerName != null ) { list . add ( String . format ( "LoggerName:%s" , loggerName ) ) ; } } ServiceReference < ? > sr = logEntry . getServiceReference ( ) ; if ( sr != null ) { String sString = String . format ( "ServiceRef:%s(id=%s, pid=%s)" , java . util . Arrays . asList ( ( String [ ] ) sr . getProperty ( "objectClass" ) ) , sr . getProperty ( "service.id" ) , sr . getProperty ( "service.pid" ) ) ; list . add ( sString ) ; } Throwable t = logEntry . getException ( ) ; if ( t != null ) { list . add ( t ) ; } Object event = logEntry . getContext ( ) ; if ( event instanceof EventObject ) { String sString = String . format ( "Event:%s" , event . toString ( ) ) ; list . add ( sString ) ; } if ( translatedMsg ) { while ( list . size ( ) < 4 ) // 4 parameters in formatted message list . add ( "" ) ; } return list . toArray ( ) ; }
Analyze available fields from the LogEntry and make a suitable object array for passing to trace .