Browse Source

Mer Super Final

AGP
Evgeny Gagua 3 years ago
parent
commit
9a70a96e21
  1. 4
      Projects/la_mojo/build
  2. 7
      lib/components/base/basicFunctionality.cpp
  3. 5
      lib/components/base/basicFunctionality.h
  4. 21
      lib/components/object/objectFileLoggingService.cpp
  5. 3
      lib/components/object/objectFileLoggingService.h

4
Projects/la_mojo/build

@ -2,10 +2,10 @@
#make clean -e "CFG=Debug"
make -e "CFG=Debug" -j6
#make -e "CFG=Debug" -j6
#make clean -e "CFG=Debug86"
#make -e "CFG=Debug86" -j4
make -e "CFG=Debug86" -j4
#make clean -e "CFG=Release86"
#make -e "CFG=Release86" -j4

7
lib/components/base/basicFunctionality.cpp

@ -163,6 +163,13 @@ bool correctSysTime( int diff ){
return true;
};
off_t getFileSize(const char *filename) {
struct stat st;
if( stat(filename, &st) == 0 ) return st.st_size;
return -1;
};
bool correctSoftTime( int diff ){
g_iTimeDiff = diff;
return true;

5
lib/components/base/basicFunctionality.h

@ -38,6 +38,9 @@
#include <VersionHelpers.h>
#include <dshow.h>
#endif
#include <sys/stat.h>
#include <sys/types.h>
#include "basicTypes.h"
int fileCopy( const char* source, const char* destination );
@ -54,6 +57,8 @@ CSTR implode( CArray *Data, CSTR S_Str, U8 Start, U8 End );
CSTR getTStr( CSTR Fmt = NULL );
CSTR getUniqID_SHA256(void);
off_t getFileSize(const char *filename) ;
int rand( int a, int b );
CSTR getUniqID_MD5(void);

21
lib/components/object/objectFileLoggingService.cpp

@ -18,6 +18,27 @@ void objectFileLoggingService::logMessage( CSTR Msg ){
void objectFileLoggingService::logMessage( const char *Msg ){
if ( m_bLogging ){
if( getFileSize( m_pFileName ) > MAX_LOG_FILE_SIZE ){
if ( MAX_LOG_FILE_BACKUPS ) {
char tB[MAX_PATH_LEN];
sprintf( tB, "%s.%d", m_pFileName, MAX_LOG_FILE_BACKUPS );
if( fileExist( tB ) ) unlink( tB );
uint8_t ix = 0;
do{
char tZ[MAX_PATH_LEN];
if ( ix ) {
sprintf( tB,"%s.%d", m_pFileName, ix++ );
sprintf( tZ,"%s.%d", m_pFileName, ix++ );
} else {
sprintf( tB,"%s", m_pFileName );
sprintf( tZ,"%s.%d", m_pFileName, ++ix );
};
rename( tB, tZ );
}while( ix < MAX_LOG_FILE_BACKUPS );
} else {
unlink( m_pFileName );
};
};
FILE *FD;
FD = fopen( m_pFileName , "a+");
if( FD != NULL ) {

3
lib/components/object/objectFileLoggingService.h

@ -10,6 +10,9 @@
*
* @author Gagua
*/
#define MAX_LOG_FILE_SIZE 4194304 //4Mega
#define MAX_LOG_FILE_BACKUPS 4
class objectFileLoggingService : public basicLoggingService {
private:
bool m_bLogging;

Loading…
Cancel
Save