Beispiel #1
0
local void Csmodlog(const char *tc, const char *params, Player *p, const Target *target)
{
	if (!strcasecmp(params, "flush"))
		FlushLog();
	else if (!strcasecmp(params, "reopen"))
		ReopenLog();
}
Beispiel #2
0
char ExtraFrameToLog(unsigned int framenumber, unsigned short x, unsigned short y,unsigned short width, unsigned short height, float bx, float by,unsigned int expt, unsigned char *buffer){
  QMutexLocker locker(&logmutex);
  if (filesaving) { 
    FILE *ofile;
    char fname[255];
    int j;
    clock_gettime(CLOCK_REALTIME, &ts);
    sprintf(fname,"frames/AFrame%06d.frm",framenumber);
    ofile = fopen(fname,"w");
    nowt = ts.tv_sec + ts.tv_nsec/1000000000.;
    j=0;
    j=fprintf(logfile1,"%5d::[%d][%d][%d][%d][%d][%d][%f][%f][%f]\n",currentlogentries,framenumber,x,y,width,height,expt,bx,by,nowt-startt);
    //  j+= fwrite(buffer,1, height*width, logfile1);
    //  j+= fprintf(logfile1, "\n::End::[%d]\n",framenumber);
    fwrite(buffer,1, height*width, ofile);
    fclose(ofile);
    totalentries++;
    if(currentlogentries == MAXENTRIES){
      ReopenLog();
    } else {
      currentlogentries++;
    };
  }
  return 0;
};
Beispiel #3
0
char WriteToLog(char *function, char *format, ...){
  QMutexLocker locker(&logmutex);
  
  
    fprintf(logfile1,"%5d::[%s]",currentlogentries,function);
    int j=0;
    va_list ap;
    va_start(ap,format);
    clock_gettime(CLOCK_REALTIME, &ts);
    nowt = ts.tv_sec + ts.tv_nsec/1000000000.;
    j = vfprintf(logfile1, format, ap);
    va_end(ap);
    j+= fprintf(logfile1,"::%lf::%lf\n",gps_utc_time,nowt-startt);
    
    totalentries++;
    
    
    if(currentlogentries == MAXENTRIES){
      ReopenLog();
    } else {
      currentlogentries++;
    };
    
    fflush(logfile1);
  
  return 0;
};
Beispiel #4
0
EXPORT int MM_log_smod(int action, Imodman *mm, Arena *arenas)
{
	if (action == MM_LOAD)
	{
		int fp;

		cfg = mm->GetInterface(I_CONFIG, ALLARENAS);
		lm = mm->GetInterface(I_LOGMAN, ALLARENAS);
		ml = mm->GetInterface(I_MAINLOOP, ALLARENAS);
		cmd = mm->GetInterface(I_CMDMAN, ALLARENAS);

		if (!cfg || !lm || !ml || !cmd) return MM_FAIL;

		logfile = NULL;
		ReopenLog();

		mm->RegCallback(CB_LOGFUNC, LogFile, ALLARENAS);

		/* cfghelp: Log:FileFlushPeriod, global, int, def: 10
		 * How often to flush the log file to disk (in minutes). */
		fp = cfg->GetInt(GLOBAL, "Log", "FileFlushPeriod", 10);

		if (fp)
			ml->SetTimer(flush_timer, fp * 60 * 100, fp * 60 * 100, NULL, NULL);

		mm->RegInterface(&_lfint, ALLARENAS);
		cmd->AddCommand("smodlog", Csmodlog, ALLARENAS, smodlog_help);

		return MM_OK;
	}
	else if (action == MM_UNLOAD)
	{
		cmd->RemoveCommand("smodlog", Csmodlog, ALLARENAS);

		if (mm->UnregInterface(&_lfint, ALLARENAS))
			return MM_FAIL;
		if (logfile)
			fclose(logfile);
		ml->ClearTimer(flush_timer, NULL);
		mm->UnregCallback(CB_LOGFUNC, LogFile, ALLARENAS);
		mm->ReleaseInterface(cmd);
		mm->ReleaseInterface(cfg);
		mm->ReleaseInterface(lm);
		mm->ReleaseInterface(ml);		
		return MM_OK;
	}
	return MM_FAIL;
}
Beispiel #5
0
char WriteToLog(char *logentry){
  QMutexLocker locker(&logmutex);
  char *filename;
  int a;

  filename = wtl_filename;

  if(logstarted !=1) return 2;

  clock_gettime(CLOCK_REALTIME, &ts);
  nowt = ts.tv_sec + ts.tv_nsec/1000000000.;

  if(filesaving){
    a = 0;
    a+=fprintf(logfile1,"%5d::%s:: ",currentlogentries,logentry);
    a+=fprintf(logfile1,"%lf, %lf\n",gps_utc_time,nowt-startt);
    
    fflush(logfile1);
  };
  //  printf("Got Here %d\t%d\n",currentlogentries,a);    
  if(a==0) return 1;

  totalentries++;
  



  //  printf("%d .. ",currentlogentries);
  if(currentlogentries == MAXENTRIES){
    
    ReopenLog();
    
  } else {
    currentlogentries++;    
  };

  //  fflush(logfile1);
  
  //  return 0;
};