public static synchronized void setTraceMemoryDestination ( String location , long maxSize ) { LogRepositoryWriter old = getBinaryHandler ( ) . getTraceWriter ( ) ; LogRepositoryWriterCBuffImpl writer ; // Check if trace writer need to be changed. if ( location == null && old instanceof LogRepositoryWriterCBuffImpl ) { writer = ( LogRepositoryWriterCBuffImpl ) old ; } else { // Get the repository manager to use for the dump writer. LogRepositoryManager manager = null ; if ( location == null && old != null ) { manager = old . getLogRepositoryManager ( ) ; } else if ( location != null ) { if ( svSuperPid != null ) manager = new LogRepositorySubManagerImpl ( new File ( location , LogRepositoryManagerImpl . TRACE_LOCATION ) , svPid , svLabel , svSuperPid ) ; else manager = new LogRepositoryManagerImpl ( new File ( location , LogRepositoryManagerImpl . TRACE_LOCATION ) , svPid , svLabel , true ) ; } if ( manager == null ) { throw new IllegalArgumentException ( "Argument 'location' can't be null if log writer was not setup by this class." ) ; } writer = new LogRepositoryWriterCBuffImpl ( new LogRepositoryWriterImpl ( manager ) ) ; } if ( maxSize > 0 ) { ( ( LogRepositoryWriterCBuffImpl ) writer ) . setMaxSize ( maxSize ) ; } else { // Stop new writer before throwing exception. if ( old != writer ) { writer . stop ( ) ; } throw new IllegalArgumentException ( "Argument 'maxSize' should be more than zero" ) ; } // Stop old manager only after successful configuration of the new writer. if ( old != null ) { LogRepositoryManager oldManager = old . getLogRepositoryManager ( ) ; if ( oldManager != null && oldManager != writer . getLogRepositoryManager ( ) ) { // Stop old writer before stopping its manager if ( old != writer ) { old . stop ( ) ; } oldManager . stop ( ) ; } } // Update writer as a last call after all data verification is done. getBinaryHandler ( ) . setTraceWriter ( writer ) ; }
Sets memory destination for trace messages .