Browse Source

Fixed File Logging and Factory Reset

Evgeny Gagua 3 years ago
parent
commit
f4298037cc
  1. 16
      Projects/la_mojo/build
  2. 3
      lib/App/mojo/mojoBackend.cpp
  3. 20
      lib/components/object/objectFileLoggingService.cpp

16
Projects/la_mojo/build

@ -2,13 +2,13 @@
#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 clean -e "CFG=Debug86"
make -e "CFG=Debug86" -j4
#make clean -e "CFG=Release86"
#make -e "CFG=Release86" -j4
#cd Release86
#strip ./mojo
#cd ..
make clean -e "CFG=Release86"
make -e "CFG=Release86" -j4
cd Release86
strip ./mojo
cd ..

3
lib/App/mojo/mojoBackend.cpp

@ -475,6 +475,9 @@ int main( int argc, char *argv[] ){
};
fileCopy( "data/factory.db", tNAME );
chown( tNAME, tUSER, tGROUP );
// delete reports cleanup
system("rm -R -f data/reports");
mkdir( "data/reports", 0755 );
};
free( tNAME );
free( tUSER );

20
lib/components/object/objectFileLoggingService.cpp

@ -23,29 +23,27 @@ void objectFileLoggingService::logMessage( const char *Msg ){
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{
uint8_t ix = MAX_LOG_FILE_BACKUPS;
while( ix ){
char tZ[MAX_PATH_LEN];
if ( ix ) {
sprintf( tB,"%s.%d", m_pFileName, ix++ );
sprintf( tZ,"%s.%d", m_pFileName, ix++ );
sprintf( tZ,"%s.%d", m_pFileName, ix );
if ( ix - 1 ) {
sprintf( tB,"%s.%d", m_pFileName, ix - 1 );
} else {
sprintf( tB,"%s", m_pFileName );
sprintf( tZ,"%s.%d", m_pFileName, ++ix );
};
rename( tB, tZ );
}while( ix < MAX_LOG_FILE_BACKUPS );
if( fileExist( tB ) ) rename( tB, tZ );
ix--;
};
} else {
unlink( m_pFileName );
};
};
FILE *FD;
FD = fopen( m_pFileName , "a+");
FD = fopen( m_pFileName , "a+");
if( FD != NULL ) {
fwrite( Msg, 1, strlen(Msg), FD );
fclose(FD);
} else {
printf( "Totally Lost\n" );
};
};
};
Loading…
Cancel
Save