#ifndef LOG2_H #define LOG2_H #include <stdio.h> class log2 { public: log2(); static void d(char* s); }; #endif // LOG2_H
#include "log2.h" #include "time.h" #include "windows.h" log2::log2() { } void log2::d(char *s) { //fp = fopen("d:/tmp123/test.txt", "w+"); FILE* pFile = fopen("logc.txt", "a"); // time_t time_log = time(NULL); // struct tm* tm_log = localtime(&time_log); // fprintf(pFile, "%04d-%02d-%02d %02d:%02d:%02d ", tm_log->tm_year + 1900, tm_log->tm_mon + 1, tm_log->tm_mday, // tm_log->tm_hour, tm_log->tm_min, tm_log->tm_sec); SYSTEMTIME st ={0}; GetLocalTime(&st); fprintf(pFile, "%04d-%02d-%02d %02d:%02d:%02d %03d ", st.wYear + 1900, st.wMonth + 1, st.wDay, st.wHour,st.wMinute, st.wSecond,st.wMilliseconds); fprintf(pFile,"%s\r\n",s); fflush(pFile); fclose(pFile); }