update clang format again

This commit is contained in:
gabime
2023-09-25 16:40:36 +03:00
parent 251c856a12
commit 0a53eafe18
104 changed files with 713 additions and 734 deletions

View File

@@ -52,7 +52,7 @@ protected:
// See system/core/liblog/logger_write.c for explanation of return value
int ret = android_log(priority, tag_.c_str(), msg_output);
if (ret == -EPERM) {
return; // !__android_log_is_loggable
return; // !__android_log_is_loggable
}
int retry_count = 0;
while ((ret == -11 /*EAGAIN*/) && (retry_count < SPDLOG_ANDROID_RETRIES)) {
@@ -74,33 +74,33 @@ private:
// __android_log_buf_write, if user explicitly provides a non-default log buffer. Otherwise,
// when using the default log buffer, always log via __android_log_write.
template <int ID = BufferID>
typename std::enable_if<ID == static_cast<int>(log_id::LOG_ID_MAIN), int>::type
android_log(int prio, const char *tag, const char *text) {
typename std::enable_if<ID == static_cast<int>(log_id::LOG_ID_MAIN), int>::type android_log(
int prio, const char *tag, const char *text) {
return __android_log_write(prio, tag, text);
}
template <int ID = BufferID>
typename std::enable_if<ID != static_cast<int>(log_id::LOG_ID_MAIN), int>::type
android_log(int prio, const char *tag, const char *text) {
typename std::enable_if<ID != static_cast<int>(log_id::LOG_ID_MAIN), int>::type android_log(
int prio, const char *tag, const char *text) {
return __android_log_buf_write(ID, prio, tag, text);
}
static android_LogPriority convert_to_android_(spdlog::level::level_enum level) {
switch (level) {
case spdlog::level::trace:
return ANDROID_LOG_VERBOSE;
case spdlog::level::debug:
return ANDROID_LOG_DEBUG;
case spdlog::level::info:
return ANDROID_LOG_INFO;
case spdlog::level::warn:
return ANDROID_LOG_WARN;
case spdlog::level::err:
return ANDROID_LOG_ERROR;
case spdlog::level::critical:
return ANDROID_LOG_FATAL;
default:
return ANDROID_LOG_DEFAULT;
case spdlog::level::trace:
return ANDROID_LOG_VERBOSE;
case spdlog::level::debug:
return ANDROID_LOG_DEBUG;
case spdlog::level::info:
return ANDROID_LOG_INFO;
case spdlog::level::warn:
return ANDROID_LOG_WARN;
case spdlog::level::err:
return ANDROID_LOG_ERROR;
case spdlog::level::critical:
return ANDROID_LOG_FATAL;
default:
return ANDROID_LOG_DEFAULT;
}
}
@@ -116,7 +116,7 @@ using android_sink_buf_mt = android_sink<std::mutex, BufferId>;
template <int BufferId = log_id::LOG_ID_MAIN>
using android_sink_buf_st = android_sink<details::null_mutex, BufferId>;
} // namespace sinks
} // namespace sinks
// Create and register android syslog logger
@@ -132,6 +132,6 @@ inline std::shared_ptr<logger> android_logger_st(const std::string &logger_name,
return Factory::template create<sinks::android_sink_st>(logger_name, tag);
}
} // namespace spdlog
} // namespace spdlog
#endif // __ANDROID__
#endif // __ANDROID__

View File

@@ -55,7 +55,7 @@ SPDLOG_INLINE void ansicolor_sink<ConsoleMutex>::log(const details::log_msg &msg
print_ccode_(reset);
// after color range
print_range_(formatted, msg.color_range_end, formatted.size());
} else // no color
} else // no color
{
print_range_(formatted, 0, formatted.size());
}
@@ -75,8 +75,8 @@ SPDLOG_INLINE void ansicolor_sink<ConsoleMutex>::set_pattern(const std::string &
}
template <typename ConsoleMutex>
SPDLOG_INLINE void
ansicolor_sink<ConsoleMutex>::set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) {
SPDLOG_INLINE void ansicolor_sink<ConsoleMutex>::set_formatter(
std::unique_ptr<spdlog::formatter> sink_formatter) {
std::lock_guard<mutex_t> lock(mutex_);
formatter_ = std::move(sink_formatter);
}
@@ -89,18 +89,18 @@ SPDLOG_INLINE bool ansicolor_sink<ConsoleMutex>::should_color() {
template <typename ConsoleMutex>
SPDLOG_INLINE void ansicolor_sink<ConsoleMutex>::set_color_mode(color_mode mode) {
switch (mode) {
case color_mode::always:
should_do_colors_ = true;
return;
case color_mode::automatic:
should_do_colors_ =
details::os::in_terminal(target_file_) && details::os::is_color_terminal();
return;
case color_mode::never:
should_do_colors_ = false;
return;
default:
should_do_colors_ = false;
case color_mode::always:
should_do_colors_ = true;
return;
case color_mode::automatic:
should_do_colors_ =
details::os::in_terminal(target_file_) && details::os::is_color_terminal();
return;
case color_mode::never:
should_do_colors_ = false;
return;
default:
should_do_colors_ = false;
}
}
@@ -131,5 +131,5 @@ template <typename ConsoleMutex>
SPDLOG_INLINE ansicolor_stderr_sink<ConsoleMutex>::ansicolor_stderr_sink(color_mode mode)
: ansicolor_sink<ConsoleMutex>(stderr, mode) {}
} // namespace sinks
} // namespace spdlog
} // namespace sinks
} // namespace spdlog

View File

@@ -107,8 +107,8 @@ using ansicolor_stdout_sink_st = ansicolor_stdout_sink<details::console_nullmute
using ansicolor_stderr_sink_mt = ansicolor_stderr_sink<details::console_mutex>;
using ansicolor_stderr_sink_st = ansicolor_stderr_sink<details::console_nullmutex>;
} // namespace sinks
} // namespace spdlog
} // namespace sinks
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "ansicolor_sink-inl.h"

View File

@@ -18,8 +18,8 @@ SPDLOG_INLINE spdlog::sinks::base_sink<Mutex>::base_sink()
: formatter_{details::make_unique<spdlog::pattern_formatter>()} {}
template <typename Mutex>
SPDLOG_INLINE
spdlog::sinks::base_sink<Mutex>::base_sink(std::unique_ptr<spdlog::formatter> formatter)
SPDLOG_INLINE spdlog::sinks::base_sink<Mutex>::base_sink(
std::unique_ptr<spdlog::formatter> formatter)
: formatter_{std::move(formatter)} {}
template <typename Mutex>

View File

@@ -43,8 +43,8 @@ protected:
virtual void set_pattern_(const std::string &pattern);
virtual void set_formatter_(std::unique_ptr<spdlog::formatter> sink_formatter);
};
} // namespace sinks
} // namespace spdlog
} // namespace sinks
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "base_sink-inl.h"

View File

@@ -38,5 +38,5 @@ SPDLOG_INLINE void basic_file_sink<Mutex>::flush_() {
file_helper_.flush();
}
} // namespace sinks
} // namespace spdlog
} // namespace sinks
} // namespace spdlog

View File

@@ -35,7 +35,7 @@ private:
using basic_file_sink_mt = basic_file_sink<std::mutex>;
using basic_file_sink_st = basic_file_sink<details::null_mutex>;
} // namespace sinks
} // namespace sinks
//
// factory functions
@@ -58,7 +58,7 @@ inline std::shared_ptr<logger> basic_logger_st(const std::string &logger_name,
event_handlers);
}
} // namespace spdlog
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "basic_file_sink-inl.h"

View File

@@ -36,7 +36,7 @@ private:
using callback_sink_mt = callback_sink<std::mutex>;
using callback_sink_st = callback_sink<details::null_mutex>;
} // namespace sinks
} // namespace sinks
//
// factory functions
@@ -53,4 +53,4 @@ inline std::shared_ptr<logger> callback_logger_st(const std::string &logger_name
return Factory::template create<sinks::callback_sink_st>(logger_name, callback);
}
} // namespace spdlog
} // namespace spdlog

View File

@@ -195,7 +195,7 @@ using daily_file_format_sink_mt = daily_file_sink<std::mutex, daily_filename_for
using daily_file_format_sink_st =
daily_file_sink<details::null_mutex, daily_filename_format_calculator>;
} // namespace sinks
} // namespace sinks
//
// factory functions
@@ -213,14 +213,14 @@ inline std::shared_ptr<logger> daily_logger_mt(const std::string &logger_name,
}
template <typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger>
daily_logger_format_mt(const std::string &logger_name,
const filename_t &filename,
int hour = 0,
int minute = 0,
bool truncate = false,
uint16_t max_files = 0,
const file_event_handlers &event_handlers = {}) {
inline std::shared_ptr<logger> daily_logger_format_mt(
const std::string &logger_name,
const filename_t &filename,
int hour = 0,
int minute = 0,
bool truncate = false,
uint16_t max_files = 0,
const file_event_handlers &event_handlers = {}) {
return Factory::template create<sinks::daily_file_format_sink_mt>(
logger_name, filename, hour, minute, truncate, max_files, event_handlers);
}
@@ -238,15 +238,15 @@ inline std::shared_ptr<logger> daily_logger_st(const std::string &logger_name,
}
template <typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger>
daily_logger_format_st(const std::string &logger_name,
const filename_t &filename,
int hour = 0,
int minute = 0,
bool truncate = false,
uint16_t max_files = 0,
const file_event_handlers &event_handlers = {}) {
inline std::shared_ptr<logger> daily_logger_format_st(
const std::string &logger_name,
const filename_t &filename,
int hour = 0,
int minute = 0,
bool truncate = false,
uint16_t max_files = 0,
const file_event_handlers &event_handlers = {}) {
return Factory::template create<sinks::daily_file_format_sink_st>(
logger_name, filename, hour, minute, truncate, max_files, event_handlers);
}
} // namespace spdlog
} // namespace spdlog

View File

@@ -77,5 +77,5 @@ protected:
using dist_sink_mt = dist_sink<std::mutex>;
using dist_sink_st = dist_sink<details::null_mutex>;
} // namespace sinks
} // namespace spdlog
} // namespace sinks
} // namespace spdlog

View File

@@ -88,5 +88,5 @@ protected:
using dup_filter_sink_mt = dup_filter_sink<std::mutex>;
using dup_filter_sink_st = dup_filter_sink<details::null_mutex>;
} // namespace sinks
} // namespace spdlog
} // namespace sinks
} // namespace spdlog

View File

@@ -164,7 +164,7 @@ private:
using hourly_file_sink_mt = hourly_file_sink<std::mutex>;
using hourly_file_sink_st = hourly_file_sink<details::null_mutex>;
} // namespace sinks
} // namespace sinks
//
// factory functions
@@ -188,4 +188,4 @@ inline std::shared_ptr<logger> hourly_logger_st(const std::string &logger_name,
return Factory::template create<sinks::hourly_file_sink_st>(logger_name, filename, truncate,
max_files, event_handlers);
}
} // namespace spdlog
} // namespace spdlog

View File

@@ -90,7 +90,7 @@ private:
using kafka_sink_mt = kafka_sink<std::mutex>;
using kafka_sink_st = kafka_sink<spdlog::details::null_mutex>;
} // namespace sinks
} // namespace sinks
template <typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger> kafka_logger_mt(const std::string &logger_name,
@@ -105,15 +105,15 @@ inline std::shared_ptr<logger> kafka_logger_st(const std::string &logger_name,
}
template <typename Factory = spdlog::async_factory>
inline std::shared_ptr<spdlog::logger>
kafka_logger_async_mt(std::string logger_name, spdlog::sinks::kafka_sink_config config) {
inline std::shared_ptr<spdlog::logger> kafka_logger_async_mt(
std::string logger_name, spdlog::sinks::kafka_sink_config config) {
return Factory::template create<sinks::kafka_sink_mt>(logger_name, config);
}
template <typename Factory = spdlog::async_factory>
inline std::shared_ptr<spdlog::logger>
kafka_logger_async_st(std::string logger_name, spdlog::sinks::kafka_sink_config config) {
inline std::shared_ptr<spdlog::logger> kafka_logger_async_st(
std::string logger_name, spdlog::sinks::kafka_sink_config config) {
return Factory::template create<sinks::kafka_sink_st>(logger_name, config);
}
} // namespace spdlog
} // namespace spdlog

View File

@@ -83,26 +83,26 @@ private:
using mongo_sink_mt = mongo_sink<std::mutex>;
using mongo_sink_st = mongo_sink<spdlog::details::null_mutex>;
} // namespace sinks
} // namespace sinks
template <typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger>
mongo_logger_mt(const std::string &logger_name,
const std::string &db_name,
const std::string &collection_name,
const std::string &uri = "mongodb://localhost:27017") {
inline std::shared_ptr<logger> mongo_logger_mt(
const std::string &logger_name,
const std::string &db_name,
const std::string &collection_name,
const std::string &uri = "mongodb://localhost:27017") {
return Factory::template create<sinks::mongo_sink_mt>(logger_name, db_name, collection_name,
uri);
}
template <typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger>
mongo_logger_st(const std::string &logger_name,
const std::string &db_name,
const std::string &collection_name,
const std::string &uri = "mongodb://localhost:27017") {
inline std::shared_ptr<logger> mongo_logger_st(
const std::string &logger_name,
const std::string &db_name,
const std::string &collection_name,
const std::string &uri = "mongodb://localhost:27017") {
return Factory::template create<sinks::mongo_sink_st>(logger_name, db_name, collection_name,
uri);
}
} // namespace spdlog
} // namespace spdlog

View File

@@ -41,7 +41,7 @@ protected:
}
memory_buf_t formatted;
base_sink<Mutex>::formatter_->format(msg, formatted);
formatted.push_back('\0'); // add a null terminator for OutputDebugString
formatted.push_back('\0'); // add a null terminator for OutputDebugString
#if defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
wmemory_buf_t wformatted;
details::os::utf8_to_wstrbuf(string_view_t(formatted.data(), formatted.size()), wformatted);
@@ -62,7 +62,7 @@ using msvc_sink_st = msvc_sink<details::null_mutex>;
using windebug_sink_mt = msvc_sink_mt;
using windebug_sink_st = msvc_sink_st;
} // namespace sinks
} // namespace spdlog
} // namespace sinks
} // namespace spdlog
#endif

View File

@@ -22,7 +22,7 @@ protected:
using null_sink_mt = null_sink<details::null_mutex>;
using null_sink_st = null_sink<details::null_mutex>;
} // namespace sinks
} // namespace sinks
template <typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger> null_logger_mt(const std::string &logger_name) {
@@ -38,4 +38,4 @@ inline std::shared_ptr<logger> null_logger_st(const std::string &logger_name) {
return null_logger;
}
} // namespace spdlog
} // namespace spdlog

View File

@@ -39,5 +39,5 @@ protected:
using ostream_sink_mt = ostream_sink<std::mutex>;
using ostream_sink_st = ostream_sink<details::null_mutex>;
} // namespace sinks
} // namespace spdlog
} // namespace sinks
} // namespace spdlog

View File

@@ -167,13 +167,13 @@ protected:
payload = QString::fromLatin1(str.data(), static_cast<int>(str.size()));
}
invoke_params params{max_lines_, // max lines
qt_text_edit_, // text edit to append to
std::move(payload), // text to append
default_color_, // default color
colors_.at(msg.level), // color to apply
color_range_start, // color range start
color_range_end}; // color range end
invoke_params params{max_lines_, // max lines
qt_text_edit_, // text edit to append to
std::move(payload), // text to append
default_color_, // default color
colors_.at(msg.level), // color to apply
color_range_start, // color range start
color_range_end}; // color range end
QMetaObject::invokeMethod(
qt_text_edit_, [params]() { invoke_method_(params); }, Qt::AutoConnection);
@@ -193,7 +193,7 @@ protected:
while (document->blockCount() > params.max_lines) {
cursor.select(QTextCursor::BlockUnderCursor);
cursor.removeSelectedText();
cursor.deleteChar(); // delete the newline after the block
cursor.deleteChar(); // delete the newline after the block
}
cursor.movePosition(QTextCursor::End);
@@ -232,7 +232,7 @@ using qt_sink_mt = qt_sink<std::mutex>;
using qt_sink_st = qt_sink<details::null_mutex>;
using qt_color_sink_mt = qt_color_sink<std::mutex>;
using qt_color_sink_st = qt_color_sink<details::null_mutex>;
} // namespace sinks
} // namespace sinks
//
// Factory functions
@@ -269,14 +269,16 @@ inline std::shared_ptr<logger> qt_logger_st(const std::string &logger_name,
}
// log to QObject
template <typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger>
qt_logger_mt(const std::string &logger_name, QObject *qt_object, const std::string &meta_method) {
inline std::shared_ptr<logger> qt_logger_mt(const std::string &logger_name,
QObject *qt_object,
const std::string &meta_method) {
return Factory::template create<sinks::qt_sink_mt>(logger_name, qt_object, meta_method);
}
template <typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger>
qt_logger_st(const std::string &logger_name, QObject *qt_object, const std::string &meta_method) {
inline std::shared_ptr<logger> qt_logger_st(const std::string &logger_name,
QObject *qt_object,
const std::string &meta_method) {
return Factory::template create<sinks::qt_sink_st>(logger_name, qt_object, meta_method);
}
@@ -299,4 +301,4 @@ inline std::shared_ptr<logger> qt_color_logger_st(const std::string &logger_name
false, is_utf8);
}
} // namespace spdlog
} // namespace spdlog

View File

@@ -62,6 +62,6 @@ private:
using ringbuffer_sink_mt = ringbuffer_sink<std::mutex>;
using ringbuffer_sink_st = ringbuffer_sink<details::null_mutex>;
} // namespace sinks
} // namespace sinks
} // namespace spdlog
} // namespace spdlog

View File

@@ -24,12 +24,12 @@ namespace spdlog {
namespace sinks {
template <typename Mutex>
SPDLOG_INLINE
rotating_file_sink<Mutex>::rotating_file_sink(filename_t base_filename,
std::size_t max_size,
std::size_t max_files,
bool rotate_on_open,
const file_event_handlers &event_handlers)
SPDLOG_INLINE rotating_file_sink<Mutex>::rotating_file_sink(
filename_t base_filename,
std::size_t max_size,
std::size_t max_files,
bool rotate_on_open,
const file_event_handlers &event_handlers)
: base_filename_(std::move(base_filename)),
max_size_(max_size),
max_files_(max_files),
@@ -42,7 +42,7 @@ rotating_file_sink<Mutex>::rotating_file_sink(filename_t base_filename,
throw_spdlog_ex("rotating sink constructor: max_files arg cannot exceed 200000");
}
file_helper_.open(calc_filename(base_filename_, 0));
current_size_ = file_helper_.size(); // expensive. called only once
current_size_ = file_helper_.size(); // expensive. called only once
if (rotate_on_open && current_size_ > 0) {
rotate_();
current_size_ = 0;
@@ -119,7 +119,7 @@ SPDLOG_INLINE void rotating_file_sink<Mutex>::rotate_() {
details::os::sleep_for_millis(100);
if (!rename_file_(src, target)) {
file_helper_.reopen(
true); // truncate the log file anyway to prevent it to grow beyond its limit!
true); // truncate the log file anyway to prevent it to grow beyond its limit!
current_size_ = 0;
throw_spdlog_ex("rotating_file_sink: failed renaming " + filename_to_str(src) +
" to " + filename_to_str(target),
@@ -140,5 +140,5 @@ SPDLOG_INLINE bool rotating_file_sink<Mutex>::rename_file_(const filename_t &src
return details::os::rename(src_filename, target_filename) == 0;
}
} // namespace sinks
} // namespace spdlog
} // namespace sinks
} // namespace spdlog

View File

@@ -55,7 +55,7 @@ private:
using rotating_file_sink_mt = rotating_file_sink<std::mutex>;
using rotating_file_sink_st = rotating_file_sink<details::null_mutex>;
} // namespace sinks
} // namespace sinks
//
// factory functions
@@ -82,7 +82,7 @@ inline std::shared_ptr<logger> rotating_logger_st(const std::string &logger_name
return Factory::template create<sinks::rotating_file_sink_st>(
logger_name, filename, max_file_size, max_files, rotate_on_open, event_handlers);
}
} // namespace spdlog
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "rotating_file_sink-inl.h"

View File

@@ -26,8 +26,8 @@ protected:
level_t level_{level::trace};
};
} // namespace sinks
} // namespace spdlog
} // namespace sinks
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "sink-inl.h"

View File

@@ -35,4 +35,4 @@ SPDLOG_INLINE std::shared_ptr<logger> stderr_color_st(const std::string &logger_
color_mode mode) {
return Factory::template create<sinks::stderr_color_sink_st>(logger_name, mode);
}
} // namespace spdlog
} // namespace spdlog

View File

@@ -24,7 +24,7 @@ using stdout_color_sink_st = ansicolor_stdout_sink_st;
using stderr_color_sink_mt = ansicolor_stderr_sink_mt;
using stderr_color_sink_st = ansicolor_stderr_sink_st;
#endif
} // namespace sinks
} // namespace sinks
template <typename Factory = spdlog::synchronous_factory>
std::shared_ptr<logger> stdout_color_mt(const std::string &logger_name,
@@ -42,7 +42,7 @@ template <typename Factory = spdlog::synchronous_factory>
std::shared_ptr<logger> stderr_color_st(const std::string &logger_name,
color_mode mode = color_mode::automatic);
} // namespace spdlog
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "stdout_color_sinks-inl.h"

View File

@@ -16,13 +16,13 @@
// so instead we use ::FileWrite
#include <spdlog/details/windows_include.h>
#ifndef _USING_V110_SDK71_ // fileapi.h doesn't exist in winxp
#include <fileapi.h> // WriteFile (..)
#ifndef _USING_V110_SDK71_ // fileapi.h doesn't exist in winxp
#include <fileapi.h> // WriteFile (..)
#endif
#include <io.h> // _get_osfhandle(..)
#include <stdio.h> // _fileno(..)
#endif // WIN32
#include <io.h> // _get_osfhandle(..)
#include <stdio.h> // _fileno(..)
#endif // WIN32
namespace spdlog {
@@ -44,7 +44,7 @@ SPDLOG_INLINE stdout_sink_base<ConsoleMutex>::stdout_sink_base(FILE *file)
if (handle_ == INVALID_HANDLE_VALUE && file != stdout && file != stderr) {
throw_spdlog_ex("spdlog::stdout_sink_base: _get_osfhandle() failed", errno);
}
#endif // WIN32
#endif // WIN32
}
template <typename ConsoleMutex>
@@ -68,8 +68,8 @@ SPDLOG_INLINE void stdout_sink_base<ConsoleMutex>::log(const details::log_msg &m
memory_buf_t formatted;
formatter_->format(msg, formatted);
::fwrite(formatted.data(), sizeof(char), formatted.size(), file_);
#endif // WIN32
::fflush(file_); // flush every line to terminal
#endif // WIN32
::fflush(file_); // flush every line to terminal
}
template <typename ConsoleMutex>
@@ -85,8 +85,8 @@ SPDLOG_INLINE void stdout_sink_base<ConsoleMutex>::set_pattern(const std::string
}
template <typename ConsoleMutex>
SPDLOG_INLINE void
stdout_sink_base<ConsoleMutex>::set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) {
SPDLOG_INLINE void stdout_sink_base<ConsoleMutex>::set_formatter(
std::unique_ptr<spdlog::formatter> sink_formatter) {
std::lock_guard<mutex_t> lock(mutex_);
formatter_ = std::move(sink_formatter);
}
@@ -101,7 +101,7 @@ template <typename ConsoleMutex>
SPDLOG_INLINE stderr_sink<ConsoleMutex>::stderr_sink()
: stdout_sink_base<ConsoleMutex>(stderr) {}
} // namespace sinks
} // namespace sinks
// factory methods
template <typename Factory>
@@ -123,4 +123,4 @@ template <typename Factory>
SPDLOG_INLINE std::shared_ptr<logger> stderr_logger_st(const std::string &logger_name) {
return Factory::template create<sinks::stderr_sink_st>(logger_name);
}
} // namespace spdlog
} // namespace spdlog

View File

@@ -41,7 +41,7 @@ protected:
std::unique_ptr<spdlog::formatter> formatter_;
#ifdef _WIN32
HANDLE handle_;
#endif // WIN32
#endif // WIN32
};
template <typename ConsoleMutex>
@@ -62,7 +62,7 @@ using stdout_sink_st = stdout_sink<details::console_nullmutex>;
using stderr_sink_mt = stderr_sink<details::console_mutex>;
using stderr_sink_st = stderr_sink<details::console_nullmutex>;
} // namespace sinks
} // namespace sinks
// factory methods
template <typename Factory = spdlog::synchronous_factory>
@@ -77,7 +77,7 @@ std::shared_ptr<logger> stderr_logger_mt(const std::string &logger_name);
template <typename Factory = spdlog::synchronous_factory>
std::shared_ptr<logger> stderr_logger_st(const std::string &logger_name);
} // namespace spdlog
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "stdout_sinks-inl.h"

View File

@@ -18,7 +18,6 @@ namespace sinks {
*/
template <typename Mutex>
class syslog_sink : public base_sink<Mutex> {
public:
syslog_sink(std::string ident, int syslog_option, int syslog_facility, bool enable_formatting)
: enable_formatting_{enable_formatting},
@@ -79,7 +78,7 @@ private:
using syslog_sink_mt = syslog_sink<std::mutex>;
using syslog_sink_st = syslog_sink<details::null_mutex>;
} // namespace sinks
} // namespace sinks
// Create and register a syslog logger
template <typename Factory = spdlog::synchronous_factory>
@@ -101,4 +100,4 @@ inline std::shared_ptr<logger> syslog_logger_st(const std::string &logger_name,
return Factory::template create<sinks::syslog_sink_st>(logger_name, syslog_ident, syslog_option,
syslog_facility, enable_formatting);
}
} // namespace spdlog
} // namespace spdlog

View File

@@ -102,7 +102,7 @@ protected:
using systemd_sink_mt = systemd_sink<std::mutex>;
using systemd_sink_st = systemd_sink<details::null_mutex>;
} // namespace sinks
} // namespace sinks
// Create and register a syslog logger
template <typename Factory = spdlog::synchronous_factory>
@@ -118,4 +118,4 @@ inline std::shared_ptr<logger> systemd_logger_st(const std::string &logger_name,
bool enable_formatting = false) {
return Factory::template create<sinks::systemd_sink_st>(logger_name, ident, enable_formatting);
}
} // namespace spdlog
} // namespace spdlog

View File

@@ -31,7 +31,7 @@ namespace sinks {
struct tcp_sink_config {
std::string server_host;
int server_port;
bool lazy_connect = false; // if true connect on first log call instead of on construction
bool lazy_connect = false; // if true connect on first log call instead of on construction
tcp_sink_config(std::string host, int port)
: server_host{std::move(host)},
@@ -71,5 +71,5 @@ protected:
using tcp_sink_mt = tcp_sink<std::mutex>;
using tcp_sink_st = tcp_sink<spdlog::details::null_mutex>;
} // namespace sinks
} // namespace spdlog
} // namespace sinks
} // namespace spdlog

View File

@@ -55,7 +55,7 @@ protected:
using udp_sink_mt = udp_sink<std::mutex>;
using udp_sink_st = udp_sink<spdlog::details::null_mutex>;
} // namespace sinks
} // namespace sinks
//
// factory functions
@@ -66,4 +66,4 @@ inline std::shared_ptr<logger> udp_logger_mt(const std::string &logger_name,
return Factory::template create<sinks::udp_sink_mt>(logger_name, skin_config);
}
} // namespace spdlog
} // namespace spdlog

View File

@@ -130,7 +130,7 @@ public:
~process_token_t() { ::CloseHandle(token_handle_); }
} current_process_token(
::GetCurrentProcess()); // GetCurrentProcess returns pseudohandle, no leak here!
::GetCurrentProcess()); // GetCurrentProcess returns pseudohandle, no leak here!
// Get the required size, this is expected to fail with ERROR_INSUFFICIENT_BUFFER and return
// the token size
@@ -155,30 +155,30 @@ public:
struct eventlog {
static WORD get_event_type(details::log_msg const &msg) {
switch (msg.level) {
case level::trace:
case level::debug:
return EVENTLOG_SUCCESS;
case level::trace:
case level::debug:
return EVENTLOG_SUCCESS;
case level::info:
return EVENTLOG_INFORMATION_TYPE;
case level::info:
return EVENTLOG_INFORMATION_TYPE;
case level::warn:
return EVENTLOG_WARNING_TYPE;
case level::warn:
return EVENTLOG_WARNING_TYPE;
case level::err:
case level::critical:
case level::off:
return EVENTLOG_ERROR_TYPE;
case level::err:
case level::critical:
case level::off:
return EVENTLOG_ERROR_TYPE;
default:
return EVENTLOG_INFORMATION_TYPE;
default:
return EVENTLOG_INFORMATION_TYPE;
}
}
static WORD get_event_category(details::log_msg const &msg) { return (WORD)msg.level; }
};
} // namespace internal
} // namespace internal
/*
* Windows Event Log sink
@@ -247,15 +247,14 @@ public:
}
~win_eventlog_sink() {
if (hEventLog_)
DeregisterEventSource(hEventLog_);
if (hEventLog_) DeregisterEventSource(hEventLog_);
}
};
} // namespace win_eventlog
} // namespace win_eventlog
using win_eventlog_sink_mt = win_eventlog::win_eventlog_sink<std::mutex>;
using win_eventlog_sink_st = win_eventlog::win_eventlog_sink<details::null_mutex>;
} // namespace sinks
} // namespace spdlog
} // namespace sinks
} // namespace spdlog

View File

@@ -20,18 +20,17 @@ SPDLOG_INLINE wincolor_sink<ConsoleMutex>::wincolor_sink(void *out_handle, color
: out_handle_(out_handle),
mutex_(ConsoleMutex::mutex()),
formatter_(details::make_unique<spdlog::pattern_formatter>()) {
set_color_mode_impl(mode);
// set level colors
colors_[level::trace] = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; // white
colors_[level::debug] = FOREGROUND_GREEN | FOREGROUND_BLUE; // cyan
colors_[level::info] = FOREGROUND_GREEN; // green
colors_[level::trace] = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; // white
colors_[level::debug] = FOREGROUND_GREEN | FOREGROUND_BLUE; // cyan
colors_[level::info] = FOREGROUND_GREEN; // green
colors_[level::warn] =
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; // intense yellow
colors_[level::err] = FOREGROUND_RED | FOREGROUND_INTENSITY; // intense red
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; // intense yellow
colors_[level::err] = FOREGROUND_RED | FOREGROUND_INTENSITY; // intense red
colors_[level::critical] = BACKGROUND_RED | FOREGROUND_RED | FOREGROUND_GREEN |
FOREGROUND_BLUE |
FOREGROUND_INTENSITY; // intense white on red background
FOREGROUND_INTENSITY; // intense white on red background
colors_[level::off] = 0;
}
@@ -69,7 +68,7 @@ void SPDLOG_INLINE wincolor_sink<ConsoleMutex>::log(const details::log_msg &msg)
// reset to orig colors
::SetConsoleTextAttribute(static_cast<HANDLE>(out_handle_), orig_attribs);
print_range_(formatted, msg.color_range_end, formatted.size());
} else // print without colors if color range is invalid (or color is disabled)
} else // print without colors if color range is invalid (or color is disabled)
{
write_to_file_(formatted);
}
@@ -126,7 +125,7 @@ wincolor_sink<ConsoleMutex>::set_foreground_color_(std::uint16_t attribs) {
auto ignored =
::SetConsoleTextAttribute(static_cast<HANDLE>(out_handle_), static_cast<WORD>(new_attribs));
(void)(ignored);
return static_cast<std::uint16_t>(orig_buffer_info.wAttributes); // return orig attribs
return static_cast<std::uint16_t>(orig_buffer_info.wAttributes); // return orig attribs
}
// print a range of formatted message to console
@@ -160,5 +159,5 @@ SPDLOG_INLINE wincolor_stdout_sink<ConsoleMutex>::wincolor_stdout_sink(color_mod
template <typename ConsoleMutex>
SPDLOG_INLINE wincolor_stderr_sink<ConsoleMutex>::wincolor_stderr_sink(color_mode mode)
: wincolor_sink<ConsoleMutex>(::GetStdHandle(STD_ERROR_HANDLE), mode) {}
} // namespace sinks
} // namespace spdlog
} // namespace sinks
} // namespace spdlog

View File

@@ -74,8 +74,8 @@ using wincolor_stdout_sink_st = wincolor_stdout_sink<details::console_nullmutex>
using wincolor_stderr_sink_mt = wincolor_stderr_sink<details::console_mutex>;
using wincolor_stderr_sink_st = wincolor_stderr_sink<details::console_nullmutex>;
} // namespace sinks
} // namespace spdlog
} // namespace sinks
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "wincolor_sink-inl.h"