45#if defined(__MINGW32__)
53#define __thread __declspec(thread)
118 virtual void Log(
Severity severity,
const std::string &msg) = 0;
119 virtual void Log(
Severity severity,
const char *format, va_list va) = 0;
121 std::string
vstrprintf(
const char* format, va_list va);
151 void Log(
Severity severity,
const std::string &msg)
override;
152 void Log(
Severity severity,
const char *format, va_list va)
override;
171 const std::string& search,
172 const std::string& before,
173 const std::string& after,
174 std::string subject);
187 void Log(
Severity severity,
const std::string &msg)
override;
188 void Log(
Severity severity,
const char *format, va_list va)
override;
195extern std::vector<std::unique_ptr<LogSink>>
g_log_sinks;
224#if defined(__MINGW32__) && !defined(__clang__)
225#define ATTR_FORMAT(n, m) __attribute__((__format__ (gnu_printf, n, m)))
227#define ATTR_FORMAT(n, m) __attribute__((__format__ (__printf__, n, m)))
229#define ATTR_NORETURN __attribute__((noreturn))
232#define ATTR_FORMAT(n, m)
246#define LogTrace(...) LogDebugTrace(__PRETTY_FUNCTION__, ##__VA_ARGS__)
248#define LogTrace(...) LogDebugTrace(__func__, __VA_ARGS__)
251ATTR_FORMAT(1, 2) void LogVerbose(const
char *format, ...);
252ATTR_FORMAT(1, 2)
void LogNotice(const
char *format, ...);
253ATTR_FORMAT(1, 2)
void LogWarning(const
char *format, ...);
254ATTR_FORMAT(1, 2)
void LogError(const
char *format, ...);
255ATTR_FORMAT(1, 2)
void LogDebug(const
char *format, ...);
256ATTR_FORMAT(2, 3)
void LogDebugTrace(const
char* function, const
char *format, ...);
257ATTR_FORMAT(1, 2) ATTR_NORETURN
void LogFatal(const
char *format, ...);
A STDLogSink that colorizes "warning" or "error" keywords.
Definition: log.h:163
std::string replace(const std::string &search, const std::string &before, const std::string &after, std::string subject)
Replaces warning keywords with ANSI escape sequences.
Definition: ColoredSTDLogSink.cpp:108
void PreprocessLine(std::string &line) override
Do any processing required to a line before printing it. Nothing in the base class.
Definition: ColoredSTDLogSink.cpp:59
A log sink writing to a FILE* file handle.
Definition: log.h:182
RAII wrapper for log indentation.
Definition: log.h:205
Base class for all log sinks.
Definition: log.h:91
unsigned int m_termWidth
Width of the console we're printing to, in characters.
Definition: log.h:132
virtual void PreprocessLine(std::string &line)
Do any processing required to a line before printing it. Nothing in the base class.
Definition: log.cpp:159
std::string WrapString(std::string str)
Wraps long lines and adds indentation as needed.
Definition: log.cpp:110
std::string GetIndentString()
Gets the indent string (for now, only used by STDLogSink)
Definition: log.cpp:104
Severity GetSeverity()
Returns the current severity / verbosity level.
Definition: log.h:103
bool m_lastMessageWasNewline
True if the last message ended in a character.
Definition: log.h:135
void SetSeverity(Severity sev)
Update the current severity level.
Definition: log.h:107
unsigned int m_indentSize
Number of spaces in one indentation.
Definition: log.h:129
Severity m_min_severity
Minimum severity of messages to be printed.
Definition: log.h:138
std::string vstrprintf(const char *format, va_list va)
Like sprintf, but self-managing a buffer with a std::string.
Definition: log.cpp:84
A log sink writing to stdout/stderr depending on severity.
Definition: log.h:146
Severity
Severity of a logging message.
Definition: log.h:61
bool ParseLoggerArguments(int &i, int argc, char *argv[], Severity &console_verbosity)
Helper function for parsing arguments that use common syntax.
Definition: log.cpp:178
@ WARNING
Something went wrong, but we'll attempt to proceed.
@ FATAL
State is totally unusable, must exit right now. Aborts the program after printing.
@ TRACE
Debug information that can be switched on/off on a per function basis.
@ NOTICE
Useful information about progress printed by default.
@ ERROR
Something went very wrong, an operation may be aborted or state may be confused.
@ DEBUG
Extremely detailed information only useful to people working on application internals.
@ VERBOSE
Detailed information end users may sometimes need, but not often.
__thread unsigned int g_logIndentLevel
The current indentation level.
Definition: log.cpp:53
ATTR_FORMAT(2, 3) void LogDebugTrace(const char *function
Just print the message at given log level, don't do anything special for warnings or errors.
std::vector< std::unique_ptr< LogSink > > g_log_sinks
The set of log sink objects logtools knows about.
Definition: log.cpp:62
std::mutex g_log_mutex
Mutex for serializing access to global logging state.
Definition: log.cpp:47
std::set< std::string > g_trace_filters
Set of classes or class::function for high verbosity trace messages.
Definition: log.cpp:76