mirror of https://github.com/tongzx/nt5src
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
1.1 KiB
78 lines
1.1 KiB
|
|
#include <mytypes.h>
|
|
#include <misclib.h>
|
|
|
|
#include <stdio.h>
|
|
#include <malloc.h>
|
|
#include <string.h>
|
|
#include <stdarg.h>
|
|
|
|
|
|
char *_LogFilename;
|
|
FILE *_LogFile;
|
|
unsigned _LogFlags;
|
|
|
|
|
|
VOID
|
|
_LogStart(
|
|
IN char *FileName
|
|
)
|
|
{
|
|
if(_LogFilename = strdup(FileName)) {
|
|
// changed to append to match requested behavior
|
|
if(_LogFile = fopen(_LogFilename,"at")) {
|
|
_Log("\n*** Logging started\n\n");
|
|
} else {
|
|
free(_LogFilename);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
VOID
|
|
_LogEnd(
|
|
VOID
|
|
)
|
|
{
|
|
if(_LogFile) {
|
|
_Log("\n*** Logging terminated\n\n");
|
|
//fflush(_LogFile);
|
|
fclose(_LogFile);
|
|
_LogFile = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
VOID
|
|
_LogSetFlags(
|
|
IN unsigned Flags
|
|
)
|
|
{
|
|
_LogFlags = Flags;
|
|
}
|
|
|
|
|
|
VOID
|
|
_Log(
|
|
IN char *FormatString,
|
|
...
|
|
)
|
|
{
|
|
va_list arglist;
|
|
|
|
if(!_LogFile) {
|
|
return;
|
|
}
|
|
|
|
va_start(arglist,FormatString);
|
|
|
|
vfprintf(_LogFile,FormatString,arglist);
|
|
|
|
va_end(arglist);
|
|
|
|
//fflush(_LogFile);
|
|
if(_LogFlags & LOGFLAG_CLOSE_REOPEN) {
|
|
fclose(_LogFile);
|
|
_LogFile = fopen(_LogFilename,"at");
|
|
}
|
|
}
|