diff -r 28839de615b4 -r 26645d81f48d loggingservices/rfilelogger/Logger/Src/Server.Cpp --- a/loggingservices/rfilelogger/Logger/Src/Server.Cpp Thu Aug 19 11:36:21 2010 +0300 +++ b/loggingservices/rfilelogger/Logger/Src/Server.Cpp Tue Aug 31 16:57:14 2010 +0300 @@ -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)