Skip to content

Commit

Permalink
Add direct printing to log functions, without passing to a string buf…
Browse files Browse the repository at this point in the history
…fer when formatting sin't needed
  • Loading branch information
llde committed Sep 4, 2024
1 parent a61749c commit 0cc3020
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions common/IDebugLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@ void IDebugLog::Log(LogLevel level, const char * fmt, va_list args)
printf("%s\n", formatBuf);
}

void IDebugLog::Log(LogLevel level, const char* fmt)
{
bool log = (level <= logLevel);
bool print = (level <= printLevel);

if (log)
Message(formatBuf);

if (print)
printf("%s\n", formatBuf);
}

/**
* Set the current message source
*/
Expand Down
6 changes: 6 additions & 0 deletions common/IDebugLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class IDebugLog
};

static void Log(LogLevel level, const char * fmt, va_list args);
static void Log(LogLevel level, const char* fmt);

static void SetSource(const char * source);
static void ClearSource(void);
Expand Down Expand Up @@ -113,6 +114,11 @@ inline void _MESSAGE(const char * fmt, ...)
va_end(args);
}

inline void _MESSAGE_D(const char* fmt)
{
gLog.Log(IDebugLog::kLevel_Message, fmt);
}

inline void _VMESSAGE(const char * fmt, ...)
{
va_list args;
Expand Down

0 comments on commit 0cc3020

Please sign in to comment.