Exemple #1
0
		void kFile::printf(const char* format, ...)const
		{
			va_list args;
			va_start( args, format );
			vfprintf_s(mp_Fp,format,args);
			va_end( args );
		}
Exemple #2
0
void CSingletonLog::FlashLog(const char *msg, ...)
{
	if (!msg)
	{
		return;
	}
	va_list args;

	SYSTEMTIME tm;
	GetLocalTime(&tm);
	char LogTime[100];
	sprintf_s(LogTime, "%02d-%02d %02d:%02d:%02d:%03d ", tm.wMonth, tm.wDay, tm.wHour, tm.wMinute, tm.wSecond, tm.wMilliseconds);
	
	cs.lock();
	fopen_s(&fp, logName, "a");
	if (!fp)
	{
		return;
	}
	fprintf_s(fp, LogTime);
	va_start(args, msg);
	vfprintf_s(fp, msg, args);
	va_end(args);
//	fprintf_s(fp, "\n");
	fflush(fp);
	fclose(fp);
	fp = NULL;
	cs.unlock();
}
Exemple #3
0
static int Write(FILE *stream, const char *format, va_list ap) {
#if defined(_WIN32) && !defined(__MINGW32__)
    return vfprintf_s(stream, format, ap);
#else
    return vfprintf(stream, format, ap);
#endif
}
Exemple #4
0
void
write_to_stream(FILE *stream, const char *fmt, ...)
{
    va_list	ap;
    int		n_print;

    va_start(ap, fmt);
    errno = 0;
#ifdef HAVE_BCI
    n_print = vfprintf_s(stream, fmt, ap);
#else
    n_print = vfprintf(stream, fmt, ap);
#endif
    va_end(ap);

    if (n_print < 0) {
#ifdef HAVE_BCI
	const char fn[] = "vfprintf_s()";
#else
	const char fn[] = "vfprintf()";
#endif

	if (errno != 0) {
	    err_ret("write_to_stream: %s returned %d", fn, n_print);
	} else {
	    err_msg("write_to_stream: %s returned %d (error)", fn, n_print);
	}

	abort();
    }
}
Exemple #5
0
 void Print(const char* format, ...)
 {
   va_list args;
   va_start(args, format);
   vfprintf_s(m_File, format, args);
   va_end(args);
   fprintf(m_File, "\n");
 }
Exemple #6
0
int __cdecl __mingw_vfprintf(
     FILE *stream,
     const char *format,
     va_list argptr 
)
{
    return vfprintf_s(stream, format, argptr);
}
Exemple #7
0
void pdefCodeWriterFile::Printf(const char* format, ...)
{
  va_list args;
  va_start(args, format);
  Indent();
  vfprintf_s(file, format, args);
  va_end(args);
}
Exemple #8
0
static void DebugMsg(const char* fmt, ...)
{
    if (!g_DebugLog) return;
    va_list args;
    va_start(args, fmt);
    vfprintf_s(g_DebugLog, fmt, args);
    fputs("\r\n", g_DebugLog);
    _fflush_nolock(g_DebugLog);
}
Exemple #9
0
		//============================================================================
		// Helper function that writes to the report file, and allows the user to use 
		// printf style formating                                                     
		//============================================================================
		int XGC_CDECL_CALL _printf( xgc_lpcstr format, ... )
		{
			va_list args;
			va_start( args, format );
			int write = vfprintf_s( m_pFileHandle, format, args );
			va_end( args );

			return write;
		}
Exemple #10
0
void XTrace(char* fmt, ...)
{
	va_list args;
	va_start(args, fmt);
#if defined(_DEBUG) || defined(PLH_SHOW_DEBUG_MESSAGES)
	vfprintf_s(stdout, fmt, args);
#endif
	va_end(args);
}
Exemple #11
0
void CLog::writeLineMessageA(const char *format, va_list argList)
{

 	if(!m_f)	//Should not happend, as this method must only be called if the writeLineHeader succeed
		throw CMWEXCEPTION(EIDMW_FILE_NOT_OPENED);

	vfprintf_s(m_f, format, argList);
	fprintf_s(m_f,"%c",'\n');
	close();
}
Exemple #12
0
int lib_fprintf(FILE* file, __format_string const char* format, ...) {
    va_list params = NULL;
    int result = 0;
    va_start(params, format);
#ifdef __STDC_WANT_SECURE_LIB__
    result = vfprintf_s(file, format, params);
#else
    result = vfprintf(file, format, params);
#endif
    va_end(params);
    return result;
}
Exemple #13
0
		void ColorPrintF(const WORD color,
			const char* format, ...)
		{
			// get a handle to the console
			HANDLE console_handle = GetStdHandle(STD_OUTPUT_HANDLE);

			// set the console color
			SetConsoleTextAttribute(console_handle, color);

			// print the formatted string
			va_list list;
			va_start(list, format); 
			vfprintf_s(stdout, format, list);
			va_end(list);

			// reset the console color back to the default
			SetConsoleTextAttribute(console_handle, 0x07);
		}
Exemple #14
0
void echo(const char * format, ...)
{
	va_list ap;
	va_start(ap, format);
	vprintf_s(format, ap);
	std::string s = CommonFunctions::FormatOutputString("logs", "CrashLog", false);
	FILE * m_file;
	fopen_s(&m_file, s.c_str(), "a");
	if(!m_file)
	{
		va_end(ap);
		return;
	}

	vfprintf_s(m_file, format, ap);
	fclose(m_file);
	va_end(ap);
}
Exemple #15
0
void p_err(char *format, ...) {

	va_list ap;
	va_start(ap, format);
#if _DBG
	init_dbgfp();
	vfprintf_s(dbgfp, format, ap);
	vprintf(format, ap);
	fflush(dbgfp);
#endif
	char tt[512];
	vsprintf_s(tt, sizeof(tt), format, ap);
	char exe[512];
	GetModuleFileNameA(NULL, exe, sizeof(exe));
	MessageBoxA(NULL, tt, exe, MB_OK);
	exit(0);
	va_end(ap);

}
Exemple #16
0
void p_err(char *format, ...) {

	va_list ap;
	va_start(ap, format);
#if _DBG
	init_dbgfp();
	vfprintf_s(dbgfp, format, ap);
	vprintf(format, ap);
	fflush(dbgfp);
#endif
	char tt[512];
	vsprintf_s(tt, sizeof(tt), format, ap);
	WCHAR exe[512];
	GetModuleFileNameW(NULL, exe, ARRAYSIZE(exe));

	WCHAR u16[512];
	utf8_to_16(tt, u16, ARRAYSIZE(u16));
	MessageBoxW(NULL, u16, exe, MB_OK);
	exit(0);
	va_end(ap);

}
Exemple #17
0
void ScriptLogger::Log(const char* fmt, char* args)
{
	char* argStart = args;

	if(logFile)
	{
		FILE *f;
		_wfopen_s(&f, logFile, L"a");
		if(f)
		{
			vfprintf_s(f, fmt, args);
			fclose(f);
		}
	}

	args = argStart;

	char buffer[MAX_LINE_LENGTH];
	int charsWritten = vsnprintf_s(buffer, MAX_LINE_LENGTH, _TRUNCATE, fmt, args);
	std::string logline(buffer);
	if(charsWritten == -1) logline += "...";

	int firstNewline = -1;
	while((firstNewline = logline.find("\n")) != -1)
	{
		logLines[currentLine].append(logline.substr(0, firstNewline));
		logline = logline.substr(firstNewline + strlen("\n"));
		currentLine = (currentLine + 1 < numLines ? currentLine + 1 : 0);
		logLines[currentLine].clear();
	}
	logLines[currentLine].append(logline.c_str());

	args = argStart;

	vprintf(fmt, args);

	args = argStart;
}
Exemple #18
0
int Logger::log( int level, char *msg, ... ) {
	uuidBufInd = 0;

	if ( this->logMode == LOG_MODE_OFF ) 
		return 0;
	if ( this->logLevel < level ) 
		return 0;

    va_start( valist, msg );

	char formatBuf[64];

	if ( this->timeStamp ) {
		time_t t_t;
		_timeb tb;
		struct tm stm;
		apb->apbtime( &t_t );
		apb->apb_ftime_s( &tb );
		localtime_s( &stm, &t_t );
		strftime( formatBuf, 64, "%H:%M:%S", &stm );
		sprintf_s( timeBuf, 64, "[%s.%3d] ", formatBuf, tb.millitm );
	}

	if ( this->logMode & LOG_MODE_COUT ) {
		if ( this->timeStamp ) printf( timeBuf );
		vprintf_s( msg, valist );
		printf( "\n" );
	}
	if ( this->logMode & LOG_MODE_FILE ) {
		if ( this->timeStamp ) fprintf( this->file, timeBuf );
		vfprintf_s( this->file, msg, valist );
		fprintf( this->file, "\n" );
		this->flush();
	}

	return 0;
}
Exemple #19
0
int
_cdecl
vprintf_s(const char *format, va_list valist)
{
    return vfprintf_s(stdout,format,valist);
}