Esempio n. 1
0
void _log_printf(int flag, const char *fmt, ...)
{
    static bool log_first;
    char log_path[MAX_PATH];
    FILE *fp;
    va_list arg;
    char date[32];
    char time[16];

    if (flag && 0 == (flag & Settings_LogFlag))
        return;

    fp = fopen(set_my_path(NULL, log_path, "blackbox.log"), "a");

    if (NULL == fp)
        return;

    if (false == log_first) {
        _strdate(date);
        _strtime(time);
        fprintf(fp, "\nStarting Log %s %s\n", date, time);
        log_first = true;
    }

    if ('\n' != *fmt) {
        _strtime(time);
        fprintf(fp, "%s  ", time);
    }

    va_start(arg, fmt);
    vfprintf(fp, fmt, arg);
    fprintf(fp, "\n");
    fclose(fp);
}
Esempio n. 2
0
// line = "04:13:01.610|DEB| ogger\logger.c| 353| Log file created (05-09-2001)"
void VEMiniLog::Print(int level, const char *pszModule, int iLineNumber, const char *pszFormat, ...)
{
	// is tracing off?
	if(level > m_nTraceLevel) return;

	// error type
	const char *errType = 
		level==-1 ? "SYS" : 
		level==-2 ? "ERR" : 
		"DEB";

 	// store time, module name & line number
	_strtime(gszParam);
	const char *pmod=strrchr(pszModule,'\\'); 
	pmod=pmod!=0?pmod+1:pszModule;
	sprintf(&gszParam[strlen(gszParam)], ".000|%s|%-13s|%04d|",errType, pmod, iLineNumber);

	// get ... parameters
    va_list	arg_ptr;
    va_start( arg_ptr, pszFormat );
    _vsnprintf( &gszParam[strlen(gszParam)], sizeof(gszParam)-strlen(gszParam), pszFormat, arg_ptr );
    va_end( arg_ptr );

	// write line of log
	FILE *fp=fopen(GetLogFileName(),"ab");
	if(fp==0) return;
	fwrite(gszParam,strlen(gszParam),1,fp);
	fwrite(ENDOFLINE,strlen(ENDOFLINE),1,fp);
	fclose(fp);
}
Esempio n. 3
0
void myThreadFunc(LPVOID lpvThreadParam) {
	int i;
	char message[100];
    char cTime[9];
	for (i = 0; i < 10; i++) {
		count++;
		strcpy(message, "Integer changed to ");
		strcat(message, itoa(count, cTime,10));
		strcat(message, " by thread ");
		strcat(message,  (char*) lpvThreadParam);
		strcat(message, " at ");
        _strtime( cTime );
		strcat(message, cTime);
		strcat(message, RETURN);
		PostMessage(winHandle, UPDATE_DATA, 0, (long)message);
		Sleep(500);
	}
	threadcount--;
	strcpy(message, "Thread ");
	strcat(message, (char*) lpvThreadParam);
	strcat(message, " exited!!!!!!!!!!!!!");
	PostMessage(winHandle, UPDATE_DATA, 0, (long)message);
	Sleep(100);
	PostMessage(winHandle, UPDATE_DATA, 0, (long)message);
	ExitThread(0);

}
Esempio n. 4
0
void LogFile::Log()
{
	// Declare variables to hold the date and time
	char	szDate[32],
				szTime[32];

	// Initialize the variables
	memset(szDate, 0, sizeof(szDate));
	memset(szTime, 0, sizeof(szTime));
	
	// Retrieve the current date
	_strdate(szDate);
	// Retrieve the current time
	_strtime(szTime);

	// Instantiate the output file stream
	ofstream filOutput;
	
	// Open the file stream
	filOutput.open(m_sName, ios::app, filebuf::sh_none);
	
	// Output the date, time, message and line terminator on a single line in the file
	filOutput << szDate << " ";
	filOutput << szTime << " - ";
	filOutput << m_sMsg << endl;
	
	// Flush everything in the buffer to the file
	filOutput.flush();
	
	// Make sure you close the file stream before we exit
	filOutput.close();
}
void ManagerState::LogWrite(const char *format, ...)
{
	char LogString[1000];
	va_list arg_ptr;
	int len;

	if (log==0)
	{
		log = fopen("ErrorLog.txt", "wt");
		_strdate(LogString);
		len = strlen(LogString);
		LogString[len++]=' ';
		_strtime( LogString+len );
		len = strlen(LogString);
		LogString[len++]=' ';
		LogString[len]=0;
	}
		
	if(strlen(format) > sizeof(LogString)-256) return;
	va_start(arg_ptr, format);
	vsprintf(LogString, format, arg_ptr);
	va_end(arg_ptr);
	if (LogString[0]==0)
		return;

	strcat(LogString, "\n");	

	fwrite(LogString, 1, strlen(LogString), log);
}
Esempio n. 6
0
void W3CLog::traceOn(std::auto_ptr<ILog> log, const std::string& appInfo, const std::string& format)
{
	m_format = ((sstring)format).split(" ");

	m_log = log;
	
	m_log->trace("");
	char date[100],time[100];
	_strtime(time);
	_strdate(date);

	std::string buffer;
	buffer = "#Software: " + appInfo;  //TRACER_FORMAT("%s %s\r\n","#Software:",id_cliente);
	m_log->trace(buffer);
	
	buffer = "#Version: 1.0";
	m_log->trace(buffer);
	
	buffer = "#Date: " + std::string(date) + std::string(" ") + time;
	m_log->trace(buffer);

	buffer = "#Fields: " + format;
	m_log->trace(buffer);

	buffer = "#Start-Date: " + std::string(date) + std::string(" ") + time;
	m_log->trace(buffer);

	



}
Esempio n. 7
0
// -----------------------------------------------------------------------
void   WriteMsgLog(char *pMsg)
{
	FILE   *fp;
	char   tmpTime[128], tmpDate[128];

	char   LogFileName[256] = {0}; 
	char   LogFileShortName[] = "\\VOIPSysMsgLogDemo.txt";
	char   MsgStr[512] = {0};
		
	if (pMsg == NULL)
		return;

	GetCurrentDirectory(MAX_FILE_NAME_LEN-32, LogFileName);
	strcat(LogFileName, LogFileShortName);

	if ((fp = fopen(LogFileName, "a+t")) == NULL)
	{
		sprintf(MsgStr, "fopen(%s) error.", LogFileName);
		AddMsg(MsgStr);		
	}
	else
	{		
		_strtime(tmpTime);
		_strdate(tmpDate);
		
		sprintf(MsgStr, "%s %s  %s\n",tmpDate ,tmpTime, pMsg);
		fwrite(MsgStr, strlen(MsgStr), 1, fp);
	}

	if (fp != NULL)
		fclose(fp);	
	
}
Esempio n. 8
0
//
//schrijfFile() for test fase. This file can you use in excel to make a grafic ot the data
//
void HeathRegulationControl::schrijfFile() {
	//wegschrijven naar file//

	FILE	*hp;

	hp = fopen("temperaturener.txt", "a");

	char dateStr [9];
	char timeStr [9];
	_strdate( dateStr);
	_strtime( timeStr);
	fprintf(hp, "%s - ", dateStr);
	fprintf(hp, "%s ", timeStr);
	fprintf(hp, "%3.2f ", calculate.getTemperatures(0));
	fprintf(hp, "%3.2f ", calculate.getTemperatures(1));
	fprintf(hp, "%3.2f ", calculate.getTemperatures(2));
	fprintf(hp, "%3.2f ", calculate.getTemperatures(3));
	fprintf(hp, "%3.2f ", calculate.getTemperatures(4));
	fprintf(hp, "%3.2f ", calculate.getTemperatures(5));
	fprintf(hp, "%3.2f ", calculate.getTemperatures(6));
	fprintf(hp, "%3.2f ", calculate.getSetpoint());
	fprintf(hp, "%3.2f ", calculate.getAverage());
	fprintf(hp, "Outdoor Temperature=%5.2f ", calculate.getTemperatures(6));
	fprintf(hp, "(Buiten_regeling_%s)", (calculate.getStateFans((4/3)-1)==1) ? "aan" : "uit");
	fprintf(hp, "%3.2f ", calculate.getMaxAverage());
	fprintf(hp, "%3.2f \n", calculate.getMinAverage());

	fclose(hp);
}
Esempio n. 9
0
void LiteLog::traceOn(const std::string& fileName, const std::string& appInfo,const long logLevel,const eOpenType& openType)
{

	m_logLevel = logLevel;
	//"SCRLdapBrowser v1.1.0"
	//"date time s-dns x-serialnumber x-nif x-certstatus x-error"
	m_log->traceOn(fileName,openType); //CONTINUE_LOG);

	char date[100],time[100];
	_strtime(time);
	_strdate(date);

	std::string buffer;
	buffer = "#Software: " + appInfo;  //TRACER_FORMAT("%s %s\r\n","#Software:",id_cliente);
	m_log->trace(buffer);
	
	buffer = "#Date: " + std::string(date) + std::string(" ") + time;
	m_log->trace(buffer);

	buffer = "#OS: " + System::getOperatingSystemId();
	m_log->trace(buffer);

	buffer = "#IE: " + System::getIEAgent() + " ;Version " + System::getIEVersion();
	m_log->trace(buffer);
}
Esempio n. 10
0
void WriteLog(const char * strMsg)
{
    char datebuf[128] , timebuf[128] , tempbuf[1024];
	_tzset();
	_strdate(datebuf);
	_strtime(timebuf);

	sprintf(tempbuf , "%s-%s\t" , datebuf , timebuf);

	char filename[128] = {0};

	string strPath = "";
	strPath = GetSiteViewRootPath();

	sprintf(filename , "%s\\fcgi-bin\\SipDownload.log" , strPath.c_str());

	FILE * pFile;
	struct _stat buf;
	if(_stat(filename , &buf) == 0)
	{
		if(buf.st_size >= 5000*1024)
		{
			pFile = fopen(filename , "w");
			if(pFile != NULL)
				fclose(pFile);
		}
	}
	pFile = fopen(filename ,"a+");	
	if(pFile != NULL)
	{
		fprintf(pFile ,"%s%s\n" , tempbuf , strMsg);
		fclose(pFile);
	}    
}
void ClockTimer::Tick()
{
    _tzset();
    // Obtain operating system-style time.
    _strtime(tmpbuf);
    notify();
}
Esempio n. 12
0
// =====================
	void dbout(void)
// =====================
{
char tmp[2000];
char mtime[100];
FILE  *fp;

	_strtime(mtime);

	sprintf(tmp,"%s: %s",mtime,dbuf);
	printf(dbuf);

	if (gdebug)
	{
		fp=fopen(glogfile,"at");
		if (!fp)
		{
		    printf("!!Cannot open logfile <%s>!!\n",glogfile);
		}
		else
		{
		    fprintf(fp,tmp);
			fclose(fp);
		}
	}
	strcpy(dbuf,"");
	return;
}
Esempio n. 13
0
/*----------------------------------------------------------------------
  hbInkey
  ----------------------------------------------------------------------*/
int hbInkey(int Tijdsduur)
{

  int Toets;
  time_t BeginTijd=0;
  char HuidigeTijd[9];

  Tijdsduur++;   /* WEGHALEN !!!!! alleen om warning te vermijden. */
  /* BeginTijd=time(NULL); */

  for(;;) {
	 /* Doe van alles en nog wat. */
	 /* Kijk of er een muistoets is ingedrukt etc. */
	 if ((time(NULL)-BeginTijd) >= 1) {
		_strtime(HuidigeTijd);
		hbPrint(TijdY,TijdX,HuidigeTijd,Kleur);
		BeginTijd=time(NULL);
	 }

	 if (bioskey(1)>0) {
		Toets=bioskey(0);
		Toets=((Toets & 0xff)==0 ? -(Toets>>8) : (Toets & 0xff));

		if (Toets==K_F1)
		  Help();
		else
		  break;
	 }
  }
Esempio n. 14
0
void words_shutdown (void) {
   int		  i;
   char		  tmpbuf[128];
   char		  filename[PATH_MAX];
   FILE		  * fp;

   _strtime ( tmpbuf );
   fprintf ( fp_log, "%s FINISH, %d all, %d succ\n", tmpbuf, s_all, s_succ );

   fclose ( fp_log );

   sprintf ( filename, "%s\\%s", wd, "freq.txt" );
   fp = fopen ( filename, "w" );

   fprintf ( fp, ";; ave_rate = %f\n;;\n", ave_rate );
   for ( i = 0; i < N_words; i ++ )
      fprintf ( fp, "%s %d %d %d\n", words[i].word, words[i].succ, words[i].all,
	 words[i].pri );
   fclose ( fp );

   sprintf ( filename, "%s\\%s", wd, "grandt.txt" );
   fp = fopen ( filename, "w" );

   fprintf ( fp, "%d\n%d\n", grand_total_succ, grand_total_all );

   fclose ( fp );
}
Esempio n. 15
0
void Logger(unsigned int lvl, char* caller, char* logline, ...)
{
	while(isLogging) Sleep(10);
	isLogging = true;
	FILE *file = fopen("Log\\ClientServer.log","a+");
	char timeStr[9];
	char logOut[1024];
	_strtime( timeStr );
	setColor(DARKGREY);
	printf("[%s] ", timeStr);
	fprintf(file, "[%s] ", timeStr);
	setColor(LIGHTCYAN);
	printf("%s: ", caller);
	fprintf(file, "%s: ", caller);
	if (lvl == lINFO) setColor(WHITE);
	else if (lvl == lWARN) setColor(YELLOW);
	else if (lvl == lERROR) setColor(RED);
	else if (lvl == lDEBUG) setColor(GREEN);
	va_list argList;
	va_start(argList, logline);
	vsnprintf(logOut, 1024, logline, argList);
	va_end(argList);
	printf("%s\n", logOut);
	fprintf(file, "%s\n", logOut);
	fclose(file);
	isLogging = false;
}
Esempio n. 16
0
// ===========================================================
// chargestring like "UNIT CHARGESTRING", returns secs per unit and charging sum
	int current_period(char *chargestring,float *charge)
// ===========================================================
{
CString tmp;
char curtime[30];
char from[10],to[10];
int	 fh,fm,th,tm,sec,count;

	_strtime(curtime);
	curtime[5]=0; // strip seconds

	count = count_tokens(chargestring);
	if (count<2)	return 0;

	get_token(chargestring,0,tmp,' ');
	sscanf(tmp,"%f",charge);	// charge unit

	for (int t=1;t<count;t++)
	{
		get_token(chargestring,t,tmp,' ');
		sscanf(tmp,"%d:%d-%d:%d=%d",&fh,&fm,&th,&tm,&sec);
		sprintf(from,"%02d:%02d",fh,fm);
		sprintf(to  ,"%02d:%02d",th,tm);

		if (strcmp(curtime,from)>=0 && strcmp(curtime,to)<0)
			return sec;
	}
	return 0;
}
Esempio n. 17
0
std::string getFormatedTime()
{
    char p_buf[ 128 ];
    _strtime( p_buf );
    std::string timestamp( p_buf );
    return timestamp;
}
Esempio n. 18
0
void Predictor::setupFile ( )
{
	char _outFile[100];
	char _dateStr[9];
	char _timeStr[9];

	_strdate( _dateStr);
    _strtime( _timeStr );

	//replaces invalid character for file names
	replaceChar( _dateStr, '/', '-' );
	replaceChar( _timeStr, ':', ' ' );

	//creates the filename for decoded data
	strcpy(_outFile, "Predicted PreLaunch Data for Launch Date ");
	strcat(_outFile, _dateStr);
	strcat(_outFile, " Time ");
	strcat(_outFile, _timeStr);
	strcat(_outFile, ".txt");
	_fpOutPredicted.open ( _outFile, ios::app );

	_fpOutPredicted <<"Callsign: "
					<< _balloon->getCallSign() <<'\n'
					<<"Area of Parachute: "
					<< _balloon->getArea() <<'\n'
					<<"CD of Balloon: "
					<< _balloon->getDragBalloon() <<'\n'
					<<"CD of Parachute: "
					<< _balloon->getDragPara() <<'\n'
					<<"Mass of Balloon: "
					<< _balloon->getMassBalloon() <<'\n'
					<<"Mass of Payload: "
					<< _balloon->getMassPayload() <<'\n'
					<<"Mass of Helium: "
					<< _balloon->getMassHelium() <<'\n'
					<<"Lift in lbs: "
					<< _balloon->getLift() <<'\n'
					<<"Burst Diameter: "
					<< _balloon->getBurst() <<'\n'
					<<"---------------------" <<'\n';

	_fpOutPredicted <<"Air Density Intercept (b): "
					<< _bAir <<'\n'
					<<"Air Density Slope (m): "
					<< _mAir <<'\n'
					<<"Air Density at Launch: "
					<< air( _balloon->getLatestPoint().getAlt() ) <<'\n'
					<<"---------------------" <<'\n';
	_fpOutPredicted <<"Volume Intercept (b): "
					<< _bVol <<'\n'
					<<"Volume Slope (m): "
					<< _mVol <<'\n'
					<<"Volume at Launch: "
					<< volume ( _balloon->getLatestPoint().getAlt() ) <<'\n'
					<<"---------------------" <<'\n';
	_fpOutPredicted <<"\n*********************"
					<<"\nPrelaunch Prediction"
					<<"\n*********************" <<"\n\n";
}
Esempio n. 19
0
void main (void)
 {
   char time[9];

   _strtime(time);

   printf("The current time is %s\n", time);
 }
Esempio n. 20
0
psoErrors psonLogTransaction( psonLogFile*      logFile,
                              int               transactionId,
                              psocErrorHandler* pError )
{
   char msg[80];
   char timeBuf[30];
   int err;
#if defined (WIN32)
   char tmpTime[9];
#else
   time_t t;
   struct tm formattedTime;
#endif

   PSO_PRE_CONDITION( pError  != NULL );
   PSO_PRE_CONDITION( logFile != NULL );
   PSO_INV_CONDITION( logFile->initialized == PSON_LOGFILE_SIGNATURE );
   PSO_INV_CONDITION( logFile->handle != -1 );
   
   memset( timeBuf, '\0', 30 );

#if defined (WIN32)
   _strdate( timeBuf );
   _strtime( tmpTime );
   strcat( timeBuf, " " );
   strcat( timeBuf, tmpTime );
#else
   t = time(NULL);
   localtime_r( &t, &formattedTime );
   strftime( timeBuf, 30, "%a %b %e %H:%M:%S %Y''", &formattedTime );
#endif

/*   fprintf(stderr, " ctime: %d %d %s %s\n", t, errno, szTime, n ); */

   /* szTime already includes a \n - part of the return value for ::ctime */
   memset( msg, '\0', 80 );
   sprintf( msg, "Committed  %d %s", transactionId, timeBuf );
   
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
   err = _write( logFile->handle, msg, strlen(msg) );
#else
   err = write( logFile->handle, msg, strlen(msg) );
#endif
   if ( err <= 0 ) {
      psocSetError( pError, PSOC_ERRNO_HANDLE, errno );
//      fprintf( stderr, "Error write log = %d\n", errno );
      return PSO_LOGFILE_ERROR;
   }
   
   err = fdatasync( logFile->handle );
   if ( err < 0 ) {
      psocSetError( pError, PSOC_ERRNO_HANDLE, errno );
//      fprintf( stderr, "Error fdatasync log = %d\n", errno );
      return PSO_LOGFILE_ERROR;
   }

   return PSO_OK;
}
Esempio n. 21
0
char *TimeStamp()
{
	char dbuffer [9];
	char tbuffer [9];

	_strdate(dbuffer);
	_strtime(tbuffer);
	wsprintf(szTimeStamp, "%s %s", dbuffer, tbuffer);
	return szTimeStamp;
}
Esempio n. 22
0
String System::getCurrentASCIITime()
{
    char tmpbuf[128];
    _strdate( tmpbuf );
    String date = tmpbuf;
    _strtime( tmpbuf );
    date.append("-");
    date.append(tmpbuf);
    return date;
}
Esempio n. 23
0
void LiteLog::traceOff()
{
	char date[100],time[100];
	_strtime(time);
	_strdate(date);
	std::string buffer;
	buffer = "#End-Date: " + std::string(date) + std::string(" ") + time;
	m_log->trace(buffer);
	m_log->traceOff();
}
Esempio n. 24
0
std::string getFormatedDateAndTime()
{
    char p_buf[ 128 ];
    _strtime( p_buf );
    std::string timestamp( p_buf );
    _strdate( p_buf );
    std::string datestamp( p_buf );

    return datestamp + " " + timestamp;
}
Esempio n. 25
0
void MMatchServer::OnAsyncCharFinalize(MAsyncJob* pJobInput)
{
	if (pJobInput->GetResult() != MASYNC_RESULT_SUCCEED) {
		char szTime[128]="";
		_strtime(szTime);

		mlog("[%s] Async DB Query(OnAsyncCharFinalize) Failed\n", szTime);
		return;
	}

}
Esempio n. 26
0
void MMatchServer::OnAsyncInsertConnLog(MAsyncJob* pJobResult)
{
	if (pJobResult->GetResult() != MASYNC_RESULT_SUCCEED) {
		char szTime[128]="";
		_strtime(szTime);

		mlog("[%s] Async DB Query(OnAsyncInsertConnLog) Failed\n", szTime);
		return;
	}		

}
Esempio n. 27
0
void InitLog( void )
{
	FILE *f;
	char t[256], d[256];

	f = fopen( "log.txt","w" );
	fprintf( f, "Log file started on %s at %s\r\n", _strdate( d ), _strtime( t ) );
	fclose( f );
	f = fopen( "memlog.txt","w" );
	fprintf( f, "Memory Alloc / Dealloc Log file started on %s at %s\r\n", _strdate( d ), _strtime( t ) );
	fclose( f );
}
Esempio n. 28
0
static void test_strtime(void)
{
    char time[16], * result;
    int hour, minute, second, count, len;

    result = _strtime(time);
    ok(result == time, "Wrong return value\n");
    len = strlen(time);
    ok(len == 8, "Wrong length: returned %d, should be 8\n", len);
    count = sscanf(time, "%02d:%02d:%02d", &hour, &minute, &second);
    ok(count == 3, "Wrong format: count = %d, should be 3\n", count);
}
Esempio n. 29
0
CProgramLog::~CProgramLog()
{
	DeleteCriticalSection(&m_kCritical);
	char buf[128];
	char tmpTime[32];
	char tmpDate[32];
	_strtime(tmpTime);
	_strdate(tmpDate);

	sprintf(buf, "EndTime: 【%s %s】\r\n", tmpDate, tmpTime);
	LogFileWrite(buf, strlen(buf));
}
Esempio n. 30
0
int PrintLog(const char * strReceive)
{
	char timebuf[128]={0},datebuf[128]={0},tempbuf[1024*10]={0};
	_strtime(timebuf);
	_strdate(datebuf);
	sprintf(tempbuf,"%s-%s",datebuf,timebuf);
	ofstream filestream;
	filestream.open("MySQLMonitor.log",ios::app);
	filestream<<tempbuf<<"\t"<<strReceive<<endl;
	filestream.close();
	return 0;
}