fix initial space when timestamp is off
This commit is contained in:
@ -118,23 +118,30 @@ void StreamVError(int line, const char* file, const char* fmt, va_list args)
|
|||||||
{
|
{
|
||||||
char timestamp[40];
|
char timestamp[40];
|
||||||
if (!(streamError || streamDebug)) return; // Error logging disabled
|
if (!(streamError || streamDebug)) return; // Error logging disabled
|
||||||
strcpy(timestamp, "");
|
int timeStamped = streamMsgTimeStamped;
|
||||||
if (streamMsgTimeStamped != 0)
|
if (timeStamped)
|
||||||
{
|
{
|
||||||
StreamPrintTimestampFunction(timestamp, 40);
|
StreamPrintTimestampFunction(timestamp, sizeof(timestamp));
|
||||||
}
|
}
|
||||||
#ifdef va_copy
|
#ifdef va_copy
|
||||||
if (StreamDebugFile)
|
if (StreamDebugFile)
|
||||||
{
|
{
|
||||||
va_list args2;
|
va_list args2;
|
||||||
va_copy(args2, args);
|
va_copy(args2, args);
|
||||||
fprintf(StreamDebugFile, "%s ", timestamp);
|
if (timeStamped)
|
||||||
|
{
|
||||||
|
fprintf(StreamDebugFile, "%s ", timestamp);
|
||||||
|
}
|
||||||
vfprintf(StreamDebugFile, fmt, args2);
|
vfprintf(StreamDebugFile, fmt, args2);
|
||||||
fflush(StreamDebugFile);
|
fflush(StreamDebugFile);
|
||||||
va_end(args2);
|
va_end(args2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "%s%s ", ansiEscape(ANSI_RED_BOLD), timestamp);
|
fprintf(stderr, "%s", ansiEscape(ANSI_RED_BOLD));
|
||||||
|
if (timeStamped)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s ", timestamp);
|
||||||
|
}
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s line %d: ", file, line);
|
fprintf(stderr, "%s line %d: ", file, line);
|
||||||
@ -147,14 +154,14 @@ int StreamDebugClass::
|
|||||||
print(const char* fmt, ...)
|
print(const char* fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
char timestamp[40];
|
|
||||||
StreamPrintTimestampFunction(timestamp, 40);
|
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
const char* f = strrchr(file, '/');
|
const char* f = strrchr(file, '/');
|
||||||
if (f) f++; else f = file;
|
if (f) f++; else f = file;
|
||||||
FILE* fp = StreamDebugFile ? StreamDebugFile : stderr;
|
FILE* fp = StreamDebugFile ? StreamDebugFile : stderr;
|
||||||
if (streamMsgTimeStamped != 0)
|
if (streamMsgTimeStamped)
|
||||||
{
|
{
|
||||||
|
char timestamp[40];
|
||||||
|
StreamPrintTimestampFunction(timestamp, sizeof(timestamp));
|
||||||
fprintf(fp, "%s ", timestamp);
|
fprintf(fp, "%s ", timestamp);
|
||||||
}
|
}
|
||||||
fprintf(fp, "%s:%d: ", f, line);
|
fprintf(fp, "%s:%d: ", f, line);
|
||||||
|
Reference in New Issue
Block a user