/* * log thread's main function */ void *LogThreadFunc( void* pArguments ) { char g_szLogInfoTemp[1024] = { 0 }; for(;;) { if( !g_bLogRun ) break; pthread_mutex_lock(&g_LogMtx); while( !GetLogHead( g_szLogInfoTemp ) ) pthread_cond_wait(&g_LogCondVar, &g_LogMtx); do { if( g_szLogInfoTemp[0] != 0 ) { _Plat_SimpleLog( g_szLogInfoTemp, 0 ); printf( "%s\n",g_szLogInfoTemp ); } g_szLogInfoTemp[0] = 0; } while( GetLogHead( g_szLogInfoTemp ) ); pthread_mutex_unlock(&g_LogMtx); /* pthread_mutex_lock(&g_LogMtx); pthread_cond_wait(&g_LogCondVar, &g_LogMtx); pthread_mutex_unlock(&g_LogMtx); if( !g_bLogRun ) break; pthread_mutex_lock(&g_LogInfoMtx); while( GetLogHead( g_szLogInfoTemp ) ) { if( g_szLogInfoTemp[0] != 0 ) { _Plat_SimpleLog( g_szLogInfoTemp, 0 ); } g_szLogInfoTemp[0] = 0; } pthread_mutex_unlock(&g_LogInfoMtx); //*/ } pthread_mutex_lock(&g_LogInfoMtx); while( GetLogHead( g_szLogInfoTemp ) ); pthread_mutex_unlock(&g_LogInfoMtx); if( g_pLogUnitHead ) { delete g_pLogUnitHead; g_pLogUnitHead = NULL;//by sun } return NULL; }
void* Plat_BlockLog( char const *pMsgFormat, ... ) { char temp[LOG_ITEM_SIZE] = {0}; va_list args; va_start( args, pMsgFormat ); int len = vsprintf( temp, pMsgFormat, args ); va_end(args); return _Plat_SimpleLog( temp ,0 ); }