void Log_Timestamp(LogType *log) { #ifndef BORLANDC // use a time function that will compile SYSTEMTIME st; GetLocalTime( &st ); Log_Output(log,"Current time is: %2.2d:%2.2d:%2.2d", (int)st.wHour, (int)st.wMinute, (int)st.wSecond ); #else struct date thedate; struct time thetime; assert(log); getdate(&thedate); gettime(&thetime); Log_Output(log,"%d/%d/%d - %2.2d:%2.2d:%2.2d : ", (int)thedate.da_mon, (int)thedate.da_day, (int)thedate.da_year, (int)thetime.ti_hour, (int)thetime.ti_min, (int)thetime.ti_sec); #endif }
int pascal WinMain ( HINSTANCE instance, HINSTANCE prev_instance, LPSTR cmd_line, int cmd_show ) { LogType *log; #if 0 log = Log_Open(LOG_TO_FILE,"test.log",LOG_RESET); Log_Timestamp(log); Log_Output(log,"test %d",1); Log_Close(&log); #endif #if 0 log = Log_Open(LOG_TO_FILE,"test.log",LOG_APPEND); Log_Timestamp(log); Log_Output(log,"test %d",3); Log_Close(&log); #endif log = Log_Open(LOG_TO_OPEN_NOTEPAD,"testn.log",LOG_APPEND); Log_Timestamp(log); Log_Output(log,"test %d",5); Log_Close(&log); #if 0 log = Log_Open(LOG_TO_NOTEPAD,"testn.log",LOG_RESET); Log_Timestamp(log); Log_Output(log,"test %d",2); Log_Close(&log); #endif #if 0 log = Log_Open(LOG_TO_NOTEPAD,"testn.log",LOG_APPEND); Log_Timestamp(log); Log_Output(log,"test %d",4); Log_Close(&log); #endif MessageBeep(-1); return 0; }
/***************************************************************************** 函 数 名 : Log_SelfTask 功能描述 : 打印自处理任务 输入参数 : VOS_UINT32 ulPara1 VOS_UINT32 ulPara2 VOS_UINT32 ulPara3 VOS_UINT32 ulPara4 输出参数 : 无 返 回 值 : VOS_VOID 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2007年4月24日 作 者 : 李霄 46160 修改内容 : 新生成函数 *****************************************************************************/ VOS_VOID Log_SelfTask(VOS_UINT32 ulPara1, VOS_UINT32 ulPara2, VOS_UINT32 ulPara3, VOS_UINT32 ulPara4) { VOS_INT32 sRet; VOS_UINT32 ulLen; /*lint -e813*/ VOS_CHAR acTmpStr[LOG_MAX_COLUMN_VAL_EX + 1]; /*lint +e813*/ ulPara1 = ulPara1; ulPara2 = ulPara2; ulPara3 = ulPara3; ulPara4 = ulPara4; Log_Init(); for(;;) { if(VOS_OK != VOS_SmP(g_stLogEnt.semOmPrint, 0)) { continue; } if (LOG_NULL_PTR == g_stLogEnt.rngOmRbufId) { continue; } if (LOG_TRUE == OM_RingBufferIsEmpty(g_stLogEnt.rngOmRbufId)) { continue; } sRet = OM_RingBufferGet(g_stLogEnt.rngOmRbufId, (VOS_CHAR*)(&ulLen), sizeof(VOS_UINT32)); if (sizeof(VOS_UINT32) != (VOS_UINT32)sRet) { continue; } if(LOG_MAX_COLUMN_VAL_EX < ulLen) { OM_RingBufferFlush(g_stLogEnt.rngOmRbufId); continue; } sRet = OM_RingBufferGet(g_stLogEnt.rngOmRbufId, acTmpStr, (VOS_INT32)ulLen); if (ulLen == (VOS_UINT32)sRet) { Log_Output(g_stLogEnt.ulLogOutput, acTmpStr, ulLen); } } }
/***************************************************************************** 函 数 名 : Log_SelfTask 功能描述 : 打印自处理任务 输入参数 : unsigned long ulPara1 unsigned long ulPara2 unsigned long ulPara3 unsigned long ulPara4 输出参数 : 无 返 回 值 : void 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2007年4月24日 作 者 : 李霄 46160 修改内容 : 新生成函数 *****************************************************************************/ void Log_SelfTask(unsigned long ulPara1, unsigned long ulPara2, unsigned long ulPara3, unsigned long ulPara4) { int sRet; unsigned long ulLen; /*lint -e813*/ char acTmpStr[LOG_MAX_COLUMN_VAL_EX + 1]; /*lint +e813*/ Log_Init(); for(;;) { if(VOS_OK != VOS_SmP(g_stLogEnt.semOmPrint, 0)) { continue; } if (LOG_NULL_PTR == g_stLogEnt.rngOmRbufId) { continue; } if (LOG_TRUE == OM_RingBufferIsEmpty(g_stLogEnt.rngOmRbufId)) { continue; } sRet = OM_RingBufferGet(g_stLogEnt.rngOmRbufId, (char*)(&ulLen), sizeof(unsigned long)); if (sizeof(unsigned long) != (unsigned long)sRet) { continue; } if(LOG_MAX_COLUMN_VAL_EX < ulLen) { OM_RingBufferFlush(g_stLogEnt.rngOmRbufId); continue; } sRet = OM_RingBufferGet(g_stLogEnt.rngOmRbufId, acTmpStr, (long)ulLen); if (ulLen == (unsigned long)sRet) { Log_Output(g_stLogEnt.ulLogOutput, acTmpStr, ulLen); } } }