45#if defined(__MINGW32__)
104 virtual void Log(
Severity severity,
const std::string &msg) = 0;
105 virtual void Log(
Severity severity,
const char *format, va_list va) = 0;
107 std::string
vstrprintf(
const char* format, va_list va);
137 void Log(
Severity severity,
const std::string &msg)
override;
138 void Log(
Severity severity,
const char *format, va_list va)
override;
157 const std::string& search,
158 const std::string& before,
159 const std::string& after,
160 std::string subject);
173 void Log(
Severity severity,
const std::string &msg)
override;
174 void Log(
Severity severity,
const char *format, va_list va)
override;
181extern std::vector<std::unique_ptr<LogSink>>
g_log_sinks;
210#if defined(__MINGW32__) && !defined(__clang__)
211#define ATTR_FORMAT(n, m) __attribute__((__format__ (gnu_printf, n, m)))
213#define ATTR_FORMAT(n, m) __attribute__((__format__ (__printf__, n, m)))
215#define ATTR_NORETURN __attribute__((noreturn))
218#define ATTR_FORMAT(n, m)
232#define LogTrace(...) LogDebugTrace(__PRETTY_FUNCTION__, ##__VA_ARGS__)
234#define LogTrace(...) LogDebugTrace(__func__, __VA_ARGS__)
237ATTR_FORMAT(1, 2) void LogVerbose(const
char *format, ...);
238ATTR_FORMAT(1, 2)
void LogNotice(const
char *format, ...);
239ATTR_FORMAT(1, 2)
void LogWarning(const
char *format, ...);
240ATTR_FORMAT(1, 2)
void LogError(const
char *format, ...);
241ATTR_FORMAT(1, 2)
void LogDebug(const
char *format, ...);
242ATTR_FORMAT(2, 3)
void LogDebugTrace(const
char* function, const
char *format, ...);
243ATTR_FORMAT(1, 2) ATTR_NORETURN
void LogFatal(const
char *format, ...);
A STDLogSink that colorizes "warning" or "error" keywords.
Definition: log.h:149
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:168
RAII wrapper for log indentation.
Definition: log.h:191
Base class for all log sinks.
Definition: log.h:81
unsigned int m_termWidth
Width of the console we're printing to, in characters.
Definition: log.h:118
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:93
bool m_lastMessageWasNewline
True if the last message ended in a character.
Definition: log.h:121
unsigned int m_indentSize
Number of spaces in one indentation.
Definition: log.h:115
Severity m_min_severity
Minimum severity of messages to be printed.
Definition: log.h:124
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:132
Severity
Severity of a logging message.
Definition: log.h:54
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.
@ 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