42 lines
649 B
C++
42 lines
649 B
C++
#include <cstdarg>
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <time.h>
|
|
|
|
#include "Utils.h"
|
|
|
|
namespace khofmann
|
|
{
|
|
void log(FILE* stream, const char* format, ...)
|
|
{
|
|
|
|
time_t rawtime;
|
|
struct tm* timeinfo;
|
|
|
|
time(&rawtime);
|
|
timeinfo = gmtime(&rawtime);
|
|
|
|
char fmt[256];
|
|
char time[256];
|
|
strcpy(time, asctime(timeinfo));
|
|
time[strlen(time) - 1] = 0;
|
|
sprintf(fmt, "[PDF - Reader Module] %s - %s", time, format);
|
|
|
|
va_list args;
|
|
va_start(args, format);
|
|
|
|
if (logFile != NULL)
|
|
{
|
|
vfprintf(logFile, fmt, args);
|
|
fflush(logFile);
|
|
}
|
|
vfprintf(stream, fmt, args);
|
|
|
|
va_end(args);
|
|
|
|
//free(fmt);
|
|
}
|
|
}
|