Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/logtools
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4bf1057286fc
Choose a base ref
...
head repository: ngscopeclient/logtools
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2b07071d5236
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Mar 8, 2017

  1. Copy the full SHA
    159f8a6 View commit details
  2. Copy the full SHA
    2b07071 View commit details
Showing with 27 additions and 0 deletions.
  1. +19 −0 log.cpp
  2. +8 −0 log.h
19 changes: 19 additions & 0 deletions log.cpp
Original file line number Diff line number Diff line change
@@ -263,6 +263,25 @@ void LogDebug(const char *format, ...)
}
}

void LogDebugTrace(const char* function, const char *format, ...)
{
lock_guard<mutex> lock(g_log_mutex);

//TODO: Check if we match a global "things we want to log" filter

va_list va;
for(auto &sink : g_log_sinks)
{
//First, print the function name prefix
sink->Log(Severity::DEBUG, string(function));

//then the message
va_start(va, format);
sink->Log(Severity::DEBUG, format, va);
va_end(va);
}
}

void Log(Severity severity, const char *format, ...)
{
lock_guard<mutex> lock(g_log_mutex);
8 changes: 8 additions & 0 deletions log.h
Original file line number Diff line number Diff line change
@@ -211,11 +211,19 @@ bool ParseLoggerArguments(
#define ATTR_NORETURN
#endif

///Helper for logging "trace" messages with the function name prepended to the message
#ifdef __GNUC__
#define LogTrace(fmt, ...) LogDebugTrace(__PRETTY_FUNCTION__, fmt, ##__VA_ARGS__)
#else
#define LogTrace(fmt, ...) LogDebugTrace(__func__, fmt, __VA_ARGS__)
#endif

ATTR_FORMAT(1, 2) void LogVerbose(const char *format, ...);
ATTR_FORMAT(1, 2) void LogNotice(const char *format, ...);
ATTR_FORMAT(1, 2) void LogWarning(const char *format, ...);
ATTR_FORMAT(1, 2) void LogError(const char *format, ...);
ATTR_FORMAT(1, 2) void LogDebug(const char *format, ...);
ATTR_FORMAT(2, 3) void LogDebugTrace(const char* function, const char *format, ...);
ATTR_FORMAT(1, 2) ATTR_NORETURN void LogFatal(const char *format, ...);

///Just print the message at given log level, don't do anything special for warnings or errors