Ejemplo n.º 1
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 );
}
Ejemplo n.º 2
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);
}
Ejemplo n.º 3
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);	
	
}
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);
}
Ejemplo n.º 5
0
std::string getFormatedDate()
{
    char p_buf[ 128 ];
    _strdate( p_buf );
    std::string datestamp( p_buf );
    return datestamp;
}
Ejemplo n.º 6
0
Archivo: time.c Proyecto: Barrell/wine
static void test_strdate(void)
{
    char date[16], * result;
    int month, day, year, count, len;
    errno_t err;

    result = _strdate(date);
    ok(result == date, "Wrong return value\n");
    len = strlen(date);
    ok(len == 8, "Wrong length: returned %d, should be 8\n", len);
    count = sscanf(date, "%02d/%02d/%02d", &month, &day, &year);
    ok(count == 3, "Wrong format: count = %d, should be 3\n", count);

    if(!p_strdate_s) {
        win_skip("Skipping _strdate_s tests\n");
        return;
    }

    errno = 0;
    err = p_strdate_s(NULL, 1);
    ok(err == EINVAL, "err = %d\n", err);
    ok(errno == EINVAL, "errno = %d\n", errno);

    date[0] = 'x';
    date[1] = 'x';
    err = p_strdate_s(date, 8);
    ok(err == ERANGE, "err = %d\n", err);
    ok(errno == ERANGE, "errno = %d\n", errno);
    ok(date[0] == '\0', "date[0] != '\\0'\n");
    ok(date[1] == 'x', "date[1] != 'x'\n");

    err = p_strdate_s(date, 9);
    ok(err == 0, "err = %x\n", err);
}
Ejemplo n.º 7
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);
}
Ejemplo n.º 8
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);
}
Ejemplo n.º 9
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();
}
Ejemplo 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);
	}    
}
Ejemplo n.º 11
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);

	



}
Ejemplo n.º 12
0
/**
* CLoggingSystem::CLoggingSystem
* @date Modified Mar 27, 2006
*/
CLoggingSystem::CLoggingSystem(void)
{
	m_ofLogFile.exceptions(std::ios::badbit | std::ios::failbit);
	try
	{
		m_ofLogFile.open("AckZombies.log");

		// Get Date
		char dbuffer[9];
		_strdate(dbuffer);

		CString sFmt = "-",
				sTitle;
		sFmt *= 80;
		sTitle.Format("%-69s %8s ", "Ack! Zombies - Cypher Edge Interactive",  dbuffer);
		m_ofLogFile << sFmt << "\n ";
		m_ofLogFile << sTitle << '\n';
		m_ofLogFile << sFmt << '\n';

	}
	catch(...)
	{
		if(m_ofLogFile.is_open())
			m_ofLogFile.close();
	}
}
Ejemplo n.º 13
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";
}
Ejemplo n.º 14
0
void main (void)
 {
   char date[9];

   _strdate(date);

   printf("The current date is %s\n", date);
 }
Ejemplo n.º 15
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;
}
Ejemplo n.º 16
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;
}
Ejemplo n.º 17
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();
}
Ejemplo n.º 18
0
String System::getCurrentASCIITime()
{
    char tmpbuf[128];
    _strdate( tmpbuf );
    String date = tmpbuf;
    _strtime( tmpbuf );
    date.append("-");
    date.append(tmpbuf);
    return date;
}
Ejemplo n.º 19
0
char *TimeStamp()
{
	char dbuffer [9];
	char tbuffer [9];

	_strdate(dbuffer);
	_strtime(tbuffer);
	wsprintf(szTimeStamp, "%s %s", dbuffer, tbuffer);
	return szTimeStamp;
}
Ejemplo n.º 20
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));
}
Ejemplo n.º 21
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;
}
Ejemplo n.º 22
0
static void test_strdate(void)
{
    char date[16], * result;
    int month, day, year, count, len;

    result = _strdate(date);
    ok(result == date, "Wrong return value\n");
    len = strlen(date);
    ok(len == 8, "Wrong length: returned %d, should be 8\n", len);
    count = sscanf(date, "%02d/%02d/%02d", &month, &day, &year);
    ok(count == 3, "Wrong format: count = %d, should be 3\n", count);
}
//******************************************************************************************
//
void	TargetNode::WritePDF()
{
	char	szFileNamePDF[_MAX_PATH];
	strcpy( szFileNamePDF, GetMakeFileName() );
	char*	pszExt = strrchr( szFileNamePDF, '.');
	if ( pszExt )
		memcpy( pszExt+1, "pdf", 5);
	else
		strcat( szFileNamePDF, ".pdf");

	if ( GetSlash() == '\\' )
		filePDF = fopen( szFileNamePDF, "w+t" );
	else
		filePDF = fopen( szFileNamePDF, "w+b" );
	if ( !filePDF )
		{
		 MessageBox(NULL, "Open file error", "MakePDF", MB_OK);
		 return;
		}

	char	szTimeBuff[40], szDateBuff[40];
	char	szBuffer[_MAX_PATH+1];

	ZeroMemory( (void*)&szBuffer, sizeof(szBuffer) );
	memset( szBuffer, '#', 80 );

//	_tzset();
	_strtime( szTimeBuff );
	_strdate( szDateBuff );

	fprintf( filePDF, "%s", szBuffer );
	fprintf( filePDF, "\n");
	fprintf( filePDF, "##\tFile was created by MakePDF %s %s", szDateBuff, szTimeBuff );
	fprintf( filePDF, "\n");
	fprintf( filePDF, "##\tMakeFile\t: %s", GetMakeFileName() );
	fprintf( filePDF, "\n");
	fprintf( filePDF, "##\tPlatform\t: %s", GetPlatformTarget() );
	fprintf( filePDF, "\n");
	fprintf( filePDF, "##\tTargetOS\t: %s", GetTargetOS() );
	fprintf( filePDF, "\n");
	fprintf( filePDF, "%s", szBuffer );
	fprintf( filePDF, "\n"); fprintf( filePDF, "\n");

	TargetNode*	pTargetPRJ = GetFirstChildPRJ();
	while ( pTargetPRJ )
		{
		 pTargetPRJ->WritePDFTree(0);
		 pTargetPRJ = pTargetPRJ->GetNext();
		}

	fclose( filePDF );
}
Ejemplo n.º 24
0
CProgramLog::CProgramLog()
{
	m_dwLastClearTime = 0;
	m_bShowPrint = true;
	InitializeCriticalSection(&m_kCritical);
	char buf[128];
	char tmpTime[32];
	char tmpDate[32];
	_strtime(tmpTime);
	_strdate(tmpDate);

	sprintf(buf, "BeginTime: 【%s %s】\r\n", tmpDate, tmpTime);
	LogFileWrite(buf, strlen(buf));
}
Ejemplo n.º 25
0
void Logger::addEntry(QString errorMessage) {
    QString ss;
    _strdate(m_dateStr);
    _strtime(m_timeStr);
    ss.append(m_dateStr);
    ss.append(" - ");
    ss.append(m_timeStr);
    ss.append(": ");
    ss.append(errorMessage);
    SLoggerLock->lock();
    logEntries->push_back(ss);
    SLoggerLock->unlock();
    emit logEntryAdded();
}
Ejemplo n.º 26
0
void
trace(const char *file, const int line, const char *function,
      enum TRACE_LEVEL level, const char *format, ...) {
    const char *tl[] = { "", "ERROR", "WARNING", "INFO", "VERBOSE" };
    FILE *output;
    char datestr[9];
    char timestr[9];
    va_list ap;

    /*  check if log needed */
    if (getenv("TRACE") == NULL || level > atoi(getenv("TRACE")))
	return;

    /*  get date and time */
#ifdef WIN32
    _strdate(datestr);
    _strtime(timestr);
#else
    time_t rawtime;
    time(&rawtime);
    strftime(datestr, 9, "%x", localtime(&rawtime));
    strftime(timestr, 9, "%X", localtime(&rawtime));
#endif

    /*  log to file */
    if (getenv("LOGFILE") != NULL)
	output = fopen(getenv("LOGFILE"), "a");

    /*  log to stdout and stderr */
    else {
	if (level == TRACE_LEVEL_ERROR)
	    output = stderr;
	else
	    output = stdout;
    }

    /*  output message */
    fprintf(output, "[%s %s] ", datestr, timestr);
    if (file && line && function)
	fprintf(output, "%s:%d:%s: ", file, line, function);
    if (level != TRACE_LEVEL_NO)
	fprintf(output, "%s: ", tl[level]);
    va_start(ap, format);
    vfprintf(output, format, ap);
    va_end(ap);

    /*  close log file */
    if (getenv("LOGFILE") != NULL)
	fclose(output);
}
Ejemplo n.º 27
0
BOOL LOGFILE::WriteTimeStamp()
{
    if (!m_fp)
	return FALSE;

    char szTime[64], szDate[64];

    _strtime(szTime);
    _strdate(szDate);

    fprintf(m_fp, "%s %s:  ", szTime, szDate);

    return TRUE;
}
Ejemplo n.º 28
0
IGraphFile *newGraphFile()
{
   IGraphFile *graphfile = NULL;
   MetaGraph *graph = new MetaGraph();
   // REMINDER: fill in some more details here:
	pstring version = "Sala.dll version";
	char tmpbuf[9];
	pstring date = pstring(_strdate(tmpbuf));
   graph->setProperties(pstring("Name"),pstring("Organisation"),pstring(date),pstring(version));
	graphfile = new IGraphFile();
	graphfile->setData(graph);
   // ensure the graph is labelled for deletion after use
   ((IGraphOrganizer *)graphfile->m_data)->setDeleteFlag();
   return graphfile;
}
Ejemplo n.º 29
0
main()
{ FILE * f;
  char * d[10];
  char * t[10];

 _strdate(d);
 _strtime(t);

 f = fopen("datetag.c","w");
 fprintf(f,"char * datetag ()\n");
 fprintf(f," { return(\n"); 
 fprintf(f,"\"%s/%s\"\n",d,t);
 fprintf(f,"   ) ; } \n");
 fclose(f);
}
Ejemplo n.º 30
0
BOOL ShouldWriteRecord(DWORD dwWrittenTime)
{
    CHAR tmpbuff[9], tmpbuff2[9];
    struct tm* pTime;

    // get current date
    _strdate(tmpbuff);

    // convert UTC time to date format
    pTime = localtime(&dwWrittenTime);
    strftime(tmpbuff2, 9, "%m/%d/%y", pTime);

    // compare strings
    return((strcmp(tmpbuff, tmpbuff2) == 0)
           ? TRUE : FALSE);
}