void CDTSYLogger::WriteFormat(TRefByValue<const TDesC8> aFmt,...) { TBuf8<KGenericBufferSize> buf; VA_LIST list; VA_START(list,aFmt); buf.FormatList(aFmt,list); TChar tmpchar; for(TInt i=0;i<buf.Length();i++) { tmpchar=buf[i]; if(!((tmpchar.IsPrint()) || (tmpchar=='\n') || (tmpchar=='\r') || (tmpchar=='\t'))) buf[i]='.'; } #ifdef __EXE__ CDTSYLogger* context=aScriptLoggerContext; #else CDTSYLogger* context=(CDTSYLogger*) Dll::Tls(); #endif if(context==NULL) { TRAPD(ret,context=CDTSYLogger::NewL()); if (ret==KErrNone) { #ifdef __EXE__ aScriptLoggerContext=context; #else Dll::SetTls(context); #endif } else return; } if(context->iValid) context->WriteRecord(buf); }
// ========================================================================== // METHOD: WriteLineL // // DESIGN: Prepend date/time, truncate, and convert unprintable characters to '.'. // ========================================================================== void CLogFileHandler::WriteLineL( const TDesC8& aSrc ) { TInt i = iOutputBuffer.Length(); iOutputBuffer.Append( aSrc ); TChar ch; while( i < iOutputBuffer.Length() ) { ch=iOutputBuffer[i]; if(!((ch.IsPrint()) || (ch==KTabChar8))) { iOutputBuffer[i]=KFullStopChar8; } // end if i++; } // end for iOutputBuffer.Append( KEndOfLineCharacters8 ); iFile.Write( KMaxTInt, iOutputBuffer ); } // END WriteLineL
// ========================================================================== // METHOD: WriteLineL // // DESIGN: // ========================================================================== void CLogFileHandler::WriteLineL( const TDesC16& aSrc ) { // Converting from Unicode to Utf8 is overkill for debug logging. Instead, just use the // check-and-dirty Append function, which converts multi-byte characters to char 1. // CnvUtfConverter::ConvertFromUnicodeToUtf8( iOutputBuffer, aSrc ); iOutputBuffer.Append( aSrc ); TChar ch; for( TInt i=0; i < iOutputBuffer.Length(); i++ ) { ch=iOutputBuffer[i]; if(!((ch.IsPrint()) || (ch==KTabChar8))) { iOutputBuffer[i]=KFullStopChar8; } // end if } // end for iOutputBuffer.Append( KEndOfLineCharacters8 ); iFile.Write( KMaxTInt, iOutputBuffer ); } // END WriteLineL