
*-- To Tell The Truth --*
Cruz
MAIL
HOME
|
 |
2001年06月12日(火) ■ |
 |
どうにかトレース |
 |
あやふやな記憶をたよりに、なんとか使えそうなトレースログ関数を作った。 ・・・が、まだレベル分けの処理にしていないので、 本開発での実用レベルではないな。
おまけにただのprintf()のパクリとしか思えないシロモノ。 こんなのでいいのか?>自分
++++++++++++++ void My_Trace::TraceLog(int iLevel, const char *SouceFile, int SouceLine, const char *format,...) { time_t ct = time(NULL); struct tm *actiontime = localtime(&ct);
gfplog = fopen(gTraceLogFileName, "a");
// 作業用変数の定義 va_list args;
// 初期化 va_start(args, format);
fprintf(gfplog, "[%s][%d][LEVEL %d][%4d/%d/%d/ %d:%d:%d]", SouceFile, SouceLine, iLevel, 1900 + actiontime->tm_year, 1 + actiontime->tm_mon, actiontime->tm_mday, actiontime->tm_hour, actiontime->tm_min, actiontime->tm_sec); vfprintf(gfplog, format, args); va_end(args);
fclose(gfplog); }
使用法: My_Trace T_Log; ・・・としてから、 T_Log.TraceLog(T_LEVEL0, __FILE__, __LINE__, "----START----\n"); こんな感じ。
T_Log.TraceLog(T_LEVEL4, __FILE__, __LINE__, "item=%dn", iIndex); こんなのもアリ。
表示例: [d:\user\project\test\testmain.cpp][32][LEVEL0][2001/6/12/ 18:24:19]----START----
++++++++++++++
さて、仕様変更(・・・じゃなくて仕様誤認識?)の箇所をなんとかしなきゃ。
|
|