00001
00011 #include "elog.h"
00012 #include <e32test.h>
00013
00014 #if defined (_DEBUG) || defined(__WINS__)
00015
00019 class TLoggerOverflow : public TDes8Overflow
00020 {
00021 public:
00022 void Overflow(TDes8& ) {}
00023 };
00024
00025
00026
00027
00028
00029 _LIT(KTheLogFile, "c:\\sidplaylog.txt");
00030 const TInt KFileOpenWritable = EFileWrite | EFileShareAny;
00031
00032
00033 void CEpocLogger::DoLog(TRefByValue<const TDesC8> aFmt, ...)
00039 {
00040
00041 VA_LIST list;
00042 VA_START(list,aFmt);
00043
00044 TLoggerOverflow logOverflow;
00045 TBuf8<256> logBuf;
00046 logBuf.AppendFormatList(aFmt,list,&logOverflow);
00047
00048 TInt ret;
00049 RFs theLogFs;
00050 RFile theLogFile;
00051
00052 ret = theLogFs.Connect();
00053 if( (ret != KErrNone) && (ret != KErrAlreadyExists) )
00054 return;
00055
00056
00057 ret = theLogFile.Open(theLogFs, KTheLogFile, KFileOpenWritable);
00058 if(ret == KErrNotFound)
00059 ret = theLogFile.Replace(theLogFs, KTheLogFile, KFileOpenWritable);
00060 if(ret != KErrNone)
00061 return;
00062
00063 TInt pos;
00064 ret = theLogFile.Seek(ESeekEnd, pos);
00065 if (ret==KErrNone)
00066 theLogFile.Write(logBuf);
00067
00068 theLogFile.Close();
00069 theLogFs.Close();
00070 }
00071
00072
00073 #endif // _DEBUG