[GME-commit] GMESRC/GME/Gme GMEEventLogger.cpp,1.2,1.3 GMEEventLogger.h,1.9,1.10

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Thu Jun 10 18:08:46 CDT 2004


Update of /var/lib/gme/GMESRC/GME/Gme
In directory braindrain:/tmp/cvs-serv23228/GME/Gme

Modified Files:
	GMEEventLogger.cpp GMEEventLogger.h 
Log Message:
changed existing event logger implementation to use new COM IMgaEventLogger

CVS User: brianw

Index: GMEEventLogger.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/Gme/GMEEventLogger.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** GMEEventLogger.cpp	5 Mar 2004 21:50:53 -0000	1.2
--- GMEEventLogger.cpp	10 Jun 2004 22:08:43 -0000	1.3
***************
*** 18,22 ****
  }
  
! BOOL CGMEEventLogger::initialized;
! FILE *CGMEEventLogger::EventLog;
! BOOL CGMEEventLogger::newLine;
\ No newline at end of file
--- 18,23 ----
  }
  
! BOOL CGMEEventLogger::initialized = FALSE;
! FILE *CGMEEventLogger::EventLog = NULL;
! BOOL CGMEEventLogger::newLine = TRUE;
! CComPtr<IMgaEventLogger> CGMEEventLogger::comLogger = NULL;
\ No newline at end of file

Index: GMEEventLogger.h
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/Gme/GMEEventLogger.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** GMEEventLogger.h	10 Mar 2004 21:11:18 -0000	1.9
--- GMEEventLogger.h	10 Jun 2004 22:08:43 -0000	1.10
***************
*** 60,132 ****
  	static void initialize(CString filePathAndName) //depracated
  	{
! 		initialized = FALSE;
! 
! 		EventLog = fopen(filePathAndName,"w");
! 
! 		if (EventLog != NULL)
! 			initialized = TRUE;
! 
  	};
  
  	static void initialize()
  	{
! 		if(!initialized) //if already initialized, don't do anything
! 		{
! 			CString path;
! 			char gmepath[200];
! 			if(SHGetSpecialFolderPath( NULL, gmepath, CSIDL_APPDATA, true)) //most likely C:\Documents and Settings\<username>\Application Data
! 			{
! 				path = CString(gmepath) + "\\GME"; // add \GME to the path
! 				_mkdir(path.GetBuffer(4)); //in case GME dir not there, make it, if this function fails because GME already exists, don't care
! 				CTime time = CTime::GetCurrentTime(); //to make unique logfile names
! 				CString CurrentTime = time.Format( "\\GME_%b-%d_%H.%M.%S.log" );
! 				EventLog = fopen(path+CurrentTime,"w");
! 
! 				if (EventLog != NULL) //fopen succeded
! 				{	
! 					initialized = TRUE;
! 					newLine = TRUE;
! 					LogGMEEvent("CGMEEventLogger::initialize\r\n");
! 				}
! 			}
! 		}
  	};
  
  	static void StopLogging()
  	{
! 		if(initialized)
! 		{
! 			LogGMEEvent("CGMEEventLogger::StopLogging\r\n");
! 			fflush(EventLog);
! 			fclose(EventLog);
! 		}
! 		initialized = FALSE;
! 		EventLog = NULL;
  	};
  
  	static void EmergencyEvent()
  	{
! 		LogGMEEvent("CGMEEventLogger::EmergencyEvent\r\n");
! 		StopLogging();
  	};
  
  	static void LogGMEEvent(CString s)
  	{
! 		if(initialized)
  		{
! 			if(newLine)
! 			{
! 				CTime time = CTime::GetCurrentTime();
! 				CString CurrentTime = time.Format("%b %d, %H:%M:%S ");
! 				fprintf(EventLog,CurrentTime);
! 				newLine = FALSE;
! 			}
! 			if(s.Find("\r\n")!=-1)
! 			{
! 				newLine = TRUE;
! 			}
! 			fprintf(EventLog,s);
! 			fflush(EventLog);
  		}
  	};
  
--- 60,92 ----
  	static void initialize(CString filePathAndName) //depracated
  	{
! 		initialize();
  	};
  
  	static void initialize()
  	{
! 		COMTHROW( comLogger.CoCreateInstance(L"Mga.MgaEventLogger"));
! 		COMTHROW( comLogger->Initialize() );
  	};
  
  	static void StopLogging()
  	{
! 		if(comLogger != NULL)
! 			COMTHROW( comLogger->StopLogging());
  	};
  
  	static void EmergencyEvent()
  	{
! 		if(comLogger != NULL)
! 			COMTHROW( comLogger->EmergencyEvent());
  	};
  
  	static void LogGMEEvent(CString s)
  	{
! 		if(comLogger != NULL)
  		{
! 			CComBSTR b = s;
! 			COMTHROW( comLogger->LogEvent(b));
  		}
+ 
  	};
  
***************
*** 134,138 ****
  	static void GMEEventPrintf(const char *format, IMgaObject *objOne, IMgaObject *objTwo, ...) //Only works in Transaction!!!!!!!!!
  	{
! 		if(initialized)
  		{
  			CString output(format);
--- 94,98 ----
  	static void GMEEventPrintf(const char *format, IMgaObject *objOne, IMgaObject *objTwo, ...) //Only works in Transaction!!!!!!!!!
  	{
! 		if(comLogger != NULL)
  		{
  			CString output(format);
***************
*** 160,173 ****
  				}
  			}
! 			CTime time = CTime::GetCurrentTime();
! 			CString CurrentTime = time.Format("%b %d, %H:%M:%S ");
! 			fprintf(EventLog,CurrentTime);
! 
  			va_list v1;
  			va_start(v1,objTwo);
! 			vfprintf(EventLog,output,v1);
  			va_end(v1);
  
! 			fflush(EventLog);
  		}
  
--- 120,132 ----
  				}
  			}
! 			char buffer[250];
  			va_list v1;
  			va_start(v1,objTwo);
! 			vsprintf(buffer,output,v1);
  			va_end(v1);
  
! 			CComBSTR b = buffer;
! 			COMTHROW( comLogger->LogEvent(b));
! 
  		}
  
***************
*** 180,183 ****
--- 139,143 ----
  	static BOOL initialized;
  	static BOOL newLine;
+ 	static CComPtr<IMgaEventLogger> comLogger; //new com object that lives in MgaUtil
  
  	



More information about the GME-commit mailing list