summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/logging/backend.cpp20
-rw-r--r--src/common/logging/log.h35
2 files changed, 1 insertions, 54 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 618be0864..aeb4249f8 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -2,11 +2,8 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <utility>
6#include <array>
7#include <cstdio>
8#include "common/assert.h" 6#include "common/assert.h"
9#include "common/common_funcs.h" // snprintf compatibility define
10#include "common/logging/backend.h" 7#include "common/logging/backend.h"
11#include "common/logging/filter.h" 8#include "common/logging/filter.h"
12#include "common/logging/log.h" 9#include "common/logging/log.h"
@@ -132,21 +129,6 @@ void SetFilter(Filter* new_filter) {
132 filter = new_filter; 129 filter = new_filter;
133} 130}
134 131
135void LogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num,
136 const char* function, const char* format, ...) {
137 if (filter && !filter->CheckMessage(log_class, log_level))
138 return;
139 std::array<char, 4 * 1024> formatting_buffer;
140 va_list args;
141 va_start(args, format);
142 vsnprintf(formatting_buffer.data(), formatting_buffer.size(), format, args);
143 va_end(args);
144 Entry entry = CreateEntry(log_class, log_level, filename, line_num, function,
145 std::string(formatting_buffer.data()));
146
147 PrintColoredMessage(entry);
148}
149
150void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename, 132void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
151 unsigned int line_num, const char* function, const char* format, 133 unsigned int line_num, const char* function, const char* format,
152 const fmt::format_args& args) { 134 const fmt::format_args& args) {
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 1b29ce6e0..48f85deac 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -92,19 +92,6 @@ enum class Class : ClassType {
92 Count ///< Total number of logging classes 92 Count ///< Total number of logging classes
93}; 93};
94 94
95/// Logs a message to the global logger.
96void LogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num,
97 const char* function,
98#ifdef _MSC_VER
99 _Printf_format_string_
100#endif
101 const char* format,
102 ...)
103#ifdef __GNUC__
104 __attribute__((format(printf, 6, 7)))
105#endif
106 ;
107
108/// Logs a message to the global logger, using fmt 95/// Logs a message to the global logger, using fmt
109void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename, 96void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
110 unsigned int line_num, const char* function, const char* format, 97 unsigned int line_num, const char* function, const char* format,
@@ -119,28 +106,6 @@ void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsig
119 106
120} // namespace Log 107} // namespace Log
121 108
122#define LOG_GENERIC(log_class, log_level, ...) \
123 ::Log::LogMessage(log_class, log_level, __FILE__, __LINE__, __func__, __VA_ARGS__)
124
125#ifdef _DEBUG
126#define LOG_TRACE(log_class, ...) \
127 LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Trace, __VA_ARGS__)
128#else
129#define LOG_TRACE(log_class, ...) (void(0))
130#endif
131
132#define LOG_DEBUG(log_class, ...) \
133 LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Debug, __VA_ARGS__)
134#define LOG_INFO(log_class, ...) \
135 LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Info, __VA_ARGS__)
136#define LOG_WARNING(log_class, ...) \
137 LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Warning, __VA_ARGS__)
138#define LOG_ERROR(log_class, ...) \
139 LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Error, __VA_ARGS__)
140#define LOG_CRITICAL(log_class, ...) \
141 LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Critical, __VA_ARGS__)
142
143// Define the fmt lib macros
144#ifdef _DEBUG 109#ifdef _DEBUG
145#define NGLOG_TRACE(log_class, ...) \ 110#define NGLOG_TRACE(log_class, ...) \
146 ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Trace, __FILE__, __LINE__, \ 111 ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Trace, __FILE__, __LINE__, \