NO

Author Topic: Log  (Read 2599 times)

Jokaste

  • Guest
Log
« on: October 24, 2017, 11:57:53 AM »
It is sometime usefull that the programs records some informations into a log file.
Here is some functions to do it.

I added an example that helps me for verifying structures aligment for the assembler.

Here is an example for using the log functions.

Code: [Select]
   Log_SetFileName(".\\Verify.log") ;

   Log_Init() ;
   Log_Start() ;

   Log("") ;
   Log("Structure SHFILEOPSTRUCT") ;
   wsprintf(_szTmp,"Taille de la structure SHFILEOPSTRUCT : %lu",sizeof(SHFILEOPSTRUCT)) ;
   Log(_szTmp) ;
   wsprintf(_szTmp,"OFFSET %4.4d ---> SHFILEOPSTRUCT  hwnd; ---> SIZE %4.4d Bytes",(LPBYTE) &_Sh.hwnd - (LPBYTE) &_Sh,sizeof(_Sh.hwnd)) ;
   Log(_szTmp) ;
   wsprintf(_szTmp,"OFFSET %4.4d ---> SHFILEOPSTRUCT  wFunc; ---> SIZE %4.4d Bytes",(LPBYTE) &_Sh.wFunc - (LPBYTE) &_Sh,sizeof(_Sh.wFunc)) ;
   Log(_szTmp) ;
   wsprintf(_szTmp,"OFFSET %4.4d ---> SHFILEOPSTRUCT  pFrom; ---> SIZE %4.4d Bytes",(LPBYTE) &_Sh.pFrom - (LPBYTE) &_Sh,sizeof(_Sh.pFrom)) ;
   Log(_szTmp) ;
   wsprintf(_szTmp,"OFFSET %4.4d ---> SHFILEOPSTRUCT  pTo; ---> SIZE %4.4d Bytes",(LPBYTE) &_Sh.pTo - (LPBYTE) &_Sh,sizeof(_Sh.pTo)) ;
   Log(_szTmp) ;
   wsprintf(_szTmp,"OFFSET %4.4d ---> SHFILEOPSTRUCT  fFlags; ---> SIZE %4.4d Bytes",(LPBYTE) &_Sh.fFlags - (LPBYTE) &_Sh,sizeof(_Sh.fFlags)) ;
   Log(_szTmp) ;
   wsprintf(_szTmp,"OFFSET %4.4d ---> SHFILEOPSTRUCT  fAnyOperationsAborted; ---> SIZE %4.4d Bytes",(LPBYTE) &_Sh.fAnyOperationsAborted - (LPBYTE) &_Sh,sizeof(_Sh.fAnyOperationsAborted)) ;
   Log(_szTmp) ;
   wsprintf(_szTmp,"OFFSET %4.4d ---> SHFILEOPSTRUCT  hNameMappings; ---> SIZE %4.4d Bytes",(LPBYTE) &_Sh.hNameMappings - (LPBYTE) &_Sh,sizeof(_Sh.hNameMappings)) ;
   Log(_szTmp) ;
   wsprintf(_szTmp,"OFFSET %4.4d ---> SHFILEOPSTRUCT  lpszProgressTitle; ---> SIZE %4.4d Bytes",(LPBYTE) &_Sh.lpszProgressTitle - (LPBYTE) &_Sh,sizeof(_Sh.lpszProgressTitle)) ;
   Log(_szTmp) ;

   Log("") ;
   Log_Stop() ;
   Log_Exit() ;

and the result

Quote
[mardi 24 octobre 2017 11:57:40] : *** Log Started ***
[mardi 24 octobre 2017 11:57:40] : Openning Log
[mardi 24 octobre 2017 11:57:40] : Log Ready
[mardi 24 octobre 2017 11:57:40] : *** Log Started ***
[mardi 24 octobre 2017 11:57:40] :
[mardi 24 octobre 2017 11:57:40] : Structure SHFILEOPSTRUCT
[mardi 24 octobre 2017 11:57:40] : Taille de la structure SHFILEOPSTRUCT : 56
[mardi 24 octobre 2017 11:57:40] : OFFSET 0000 ---> SHFILEOPSTRUCT  hwnd; ---> SIZE 0008 Bytes
[mardi 24 octobre 2017 11:57:40] : OFFSET 0008 ---> SHFILEOPSTRUCT  wFunc; ---> SIZE 0004 Bytes
[mardi 24 octobre 2017 11:57:40] : OFFSET 0016 ---> SHFILEOPSTRUCT  pFrom; ---> SIZE 0008 Bytes
[mardi 24 octobre 2017 11:57:40] : OFFSET 0024 ---> SHFILEOPSTRUCT  pTo; ---> SIZE 0008 Bytes
[mardi 24 octobre 2017 11:57:40] : OFFSET 0032 ---> SHFILEOPSTRUCT  fFlags; ---> SIZE 0002 Bytes
[mardi 24 octobre 2017 11:57:40] : OFFSET 0036 ---> SHFILEOPSTRUCT  fAnyOperationsAborted; ---> SIZE 0004 Bytes
[mardi 24 octobre 2017 11:57:40] : OFFSET 0040 ---> SHFILEOPSTRUCT  hNameMappings; ---> SIZE 0008 Bytes
[mardi 24 octobre 2017 11:57:40] : OFFSET 0048 ---> SHFILEOPSTRUCT  lpszProgressTitle; ---> SIZE 0008 Bytes
[mardi 24 octobre 2017 11:57:40] :
[mardi 24 octobre 2017 11:57:40] : *** Log Stoped ***
[mardi 24 octobre 2017 11:57:40] : *** Log Started ***
[mardi 24 octobre 2017 11:57:40] : Closing Log file
[mardi 24 octobre 2017 11:57:40] : *** Log Stoped ***
« Last Edit: October 24, 2017, 12:00:25 PM by Jokaste »