Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

elog.cpp

Go to the documentation of this file.
00001 // ELOG.CPP
00002 //
00003 // (c) 2000-2001 Alfred E. Heggestad
00004 //
00005 //    This program is free software; you can redistribute it and/or modify
00006 //    it under the terms of the GNU General Public License version 2 as
00007 //    published by the Free Software Foundation.
00008 //
00009 
00016 #include "elog.h"
00017 
00018 #if defined (_DEBUG)
00019 
00020 _LIT(KTheLogFile, "c:\\e32frodo.log");
00021 const TInt KFileOpenWritable = EFileWrite | EFileShareAny | EFileStream;
00022 
00023 //
00024 // local variables
00025 //
00026 
00027 class TLoggerOverflow : public TDes8Overflow
00028         {
00029 public:
00030         void Overflow(TDes8& /*aDes*/) {}
00031         };
00032 
00033 
00034 void CEpocLogger::DoLog(TRefByValue<const TDesC8> aFmt, ...)
00040         {
00041         // get the Variable Argument list (...)
00042         VA_LIST list;
00043         VA_START(list,aFmt);
00044 
00045         TLoggerOverflow logOverflow;
00046         TBuf8<256> logBuf;
00047         logBuf.AppendFormatList(aFmt,list,&logOverflow);
00048 
00049         TInt ret;
00050         RFs theLogFs;
00051         RFile theLogFile;
00052 
00053         ret = theLogFs.Connect();
00054         if( (ret != KErrNone) && (ret != KErrAlreadyExists) )
00055                 return;
00056 
00057         // try to open to old one first
00058         ret = theLogFile.Open(theLogFs, KTheLogFile, KFileOpenWritable);
00059         if(ret == KErrNotFound)
00060                 ret = theLogFile.Replace(theLogFs, KTheLogFile, KFileOpenWritable);
00061         if(ret != KErrNone)
00062                 return;
00063 
00064         TInt pos;
00065         ret = theLogFile.Seek(ESeekEnd, pos);
00066         if (ret==KErrNone)
00067                 theLogFile.Write(logBuf);
00068 
00069         theLogFile.Close(); // close it so that 'tail -f logfile.txt' can display changes
00070         theLogFs.Close();
00071         }
00072 
00073 
00074 #endif // _DEBUG

Generated on Tue Feb 8 04:07:53 2005 for E32frodo by doxygen 1.3.3