// ==========================================================================
// METHOD:  Initialize
//
// DESIGN:  
// ==========================================================================
TBool CDebugLogTlsData::Initialize()
    {
    TInt returnValue = ( iFs.Connect() == KErrNone );
    
    if( returnValue )
        {
        // Request notification of directory adds/deletes in the logs directory.
        iFs.NotifyChange( ENotifyDir, iStatus, KDebugLogsBaseDirectory );        
        SetActive();
        
    	// Dynamically create the name of the log files based on the application name
    	// and thread ID.  This will eliminate multiple processes/thread usage of
    	// this debug logging infrastructure from scribbling each others traces.
	    RProcess thisProcess;
   	    RThread  thisThread;

	    // The file name is the process name followed by the thread ID.
    	TParsePtrC fileNameParser( thisProcess.FileName() );
    	iFileName.Copy( fileNameParser.Name() );
    	iFileName.Append( KUnderscore );
    	iFileName.Append( thisThread.Name() );    	    	
    	iFileName.Append( KDebugLogFileExt );    	       
        
        } // end if
        
    return returnValue;        

    } // END Initialize
// ==========================================================================
// METHOD:  RunL
//
// DESIGN:  
// ==========================================================================
void CDebugLogTlsData::RunL()
    {
    if( iStatus == KErrNone )
        {
        // Try to open each file, just in case the modified directory was
        // for one of the log files.
        for( TInt i = 0; i < iFiles.Count(); i++ )
            {
    	    iFiles[i]->TryToOpenFile( ETrue );
            } // end for
	        
        iFs.NotifyChange( ENotifyDir, iStatus, KDebugLogsBaseDirectory );
        SetActive();
        
        } // end if
        
    } // END RunL