22 YarprunCheckpoints::YarprunCheckpoints()
27 time_t
now=time(
nullptr);
29 sprintf(path,
"C:/Users/user/Documents/yarprun_log/yarprun_log_%d_%s_%u.txt", GetCurrentProcessId(), ctime(&
now), (
unsigned)rand());
32 gettimeofday(&
now,
nullptr);
33 sprintf(path,
"/tmp/yarprun_log_%d_%s_%06d.txt",
getpid(), ctime(&(
now.tv_sec)), (
int)
now.tv_usec);
36 for (
int t=10;
t<256 && path[
t]; ++
t)
38 if (path[
t]==
'\n' || path[
t]==
'\r' || path[
t]==
' ' || path[
t]==
':' || path[
t]==
'?') path[
t]=
'_';
41 mLogFile=fopen(path,
"w");
43 if (!mLogFile) perror(path);
48 if (mLogFile) fclose(mLogFile);
60 if (!mLogFile)
return;
62 fprintf(mLogFile,
"%s: file %s function %s line %d\n", prefix, sFile, sFunction, line);
static YarprunCheckpoints & instance()
void checkpoint(const char *prefix, const char *sFile, const char *sFunction, int line)
double now()
Return the current time in seconds, relative to an arbitrary starting point.
int getpid()
Portable wrapper for the getppid() function.