diff -r 7a522c0700d3 -r cce6680bbf1c loggingservices/rfilelogger/Logger/Src/Server.Cpp --- a/loggingservices/rfilelogger/Logger/Src/Server.Cpp Fri May 14 13:32:10 2010 +0100 +++ b/loggingservices/rfilelogger/Logger/Src/Server.Cpp Thu Jul 01 17:02:22 2010 +0100 @@ -382,27 +382,28 @@ aCount[0]=0; TInt posI(0); -// retrive log message: + // retrive log message: // Retrive common part of log message: - for(TInt i = 1; i<6; i++) + TInt i=0; + for(i=1; i<6; i++) { SearchBuf.Set(aPtr.Mid(posI)); aCount[i]=SearchBuf.Find(KSeperation8)+posI; posI=aCount[i]+3; if(aCount[i]" - //It shoud happened once at the beginning of the file - // such as overwrite mode - { - afileSize=12; // used for lock position - alogbuf.Copy(KxmlHeader); - } - alogbuf.Append(_L8("\r\n\r\n")); - for(TInt i=0; i<6; i++) - { - alogbuf.Append(_L8(" <")); - alogbuf.Append(alogField[i].iLogTag8); - alogbuf.Append(_L8(">")); - alogbuf.Append(alogField[i].iLogValue8); - alogbuf.Append(_L8("\r\n")); - } - for(TInt i=0; i")); - alogbuf.Append(extralogField[i].iLogValue8); - alogbuf.Append(_L8("\r\n")); - } - - alogbuf.Append(_L8("")); - alogbuf.Append(_L8("\r\n")); - - iLogFile.Write(afileSize-12, alogbuf,iStatus); - - - if(!r) - { - mutex.Signal(); - mutex.Close(); - } - - if(extralogField) delete[] extralogField; + } + // Start to organize an XML format: + TInt afileSize; + _LIT(KLogMutex, "LoggingServerMutex"); + RMutex mutex; + TInt r = mutex.CreateGlobal(KLogMutex); + if(r==KErrAlreadyExists) + r = mutex.OpenGlobal(KLogMutex); + + if(!r) + mutex.Wait(); // If still failed, let logging go without bother the mutex. + iLogFile.Size(afileSize); + if(afileSize<12) // 12 is from charters of "\r\n" + //It shoud happened once at the beginning of the file + // such as overwrite mode + { + afileSize=12; // used for lock position + alogbuf.Copy(KxmlHeader); + } + alogbuf.Append(_L8("\r\n\r\n")); + for(TInt i=0; i<6; i++) + { + alogbuf.Append(_L8(" <")); + alogbuf.Append(alogField[i].iLogTag8); + alogbuf.Append(_L8(">")); + alogbuf.Append(alogField[i].iLogValue8); + alogbuf.Append(_L8("\r\n")); + } + for(TInt i=0; i")); + alogbuf.Append(extralogField[i].iLogValue8); + alogbuf.Append(_L8("\r\n")); + } + + alogbuf.Append(_L8("")); + alogbuf.Append(_L8("\r\n")); + + iLogFile.Write(afileSize-12, alogbuf,iStatus); + + if(!r) + { + mutex.Signal(); + mutex.Close(); + } + + if(extralogField) + delete[] extralogField; + delete[] alogField; delete pBuf1; - } void CLogFileControl::WriteTxt(const TDesC8 &aDes)