예제 #1
0
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);
	}
// This is only an approximation. The semantics are not exactly the
// same, and hence we are using a different name.
//
// Note that this implementation is not general purpose, since the
// size of the internal buffer is limited.
extern "C" void g_string_append_printf_fix(GString *gs,
					   const gchar *format,
					   ...)
{
  static const int bufSize = 100;
  TBuf8<bufSize> buf;

  VA_LIST argp;
  VA_START(argp, format);

  TPtrC8 fmt((TUint8*)format); // like strlen for length
  buf.FormatList(fmt, argp);

  // may throw a GLib OOM error on Symbian
  g_string_append(gs, (gchar*)buf.PtrZ());

#if 0
  char buf[bufSize];

  va_list argp;
  va_start(argp, fmt);
  // vsnprintf would be safer but itself buggy.
  int ret = vsprintf(buf, fmt, argp);
  va_end(argp); // any cleanup

  if (ret >= 0 && ret < bufSize) {
    // No error, and everything did fit.
    g_string_append(gs, buf);
  } else {
    assert(ret < bufSize && "likely memory corruption");
  }
#endif
}
예제 #3
0
// ----------------------------------------------------------
// TXdmSettingsApi::WriteToLog
//
// ----------------------------------------------------------
//
void TXdmSettingsApi::WriteToLog( TRefByValue<const TDesC8> aFmt,... )
{
    VA_LIST list;
    VA_START( list, aFmt );
    TBuf8<KXdmSettingsLogBufferMaxSize> buf;
    buf.FormatList( aFmt, list );
    RFileLogger::Write( KXdmSettingsLogDir, KXdmSettingsLogFile,
                        EFileLoggingModeAppend, buf );
}