mirror of
https://github.com/gabime/spdlog.git
synced 2025-10-02 03:19:02 +08:00
update clang format again
This commit is contained in:
@@ -50,7 +50,7 @@ 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());
|
||||
}
|
||||
@@ -84,18 +84,18 @@ bool ansicolor_sink<ConsoleMutex>::should_color() {
|
||||
template <typename ConsoleMutex>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,8 +126,8 @@ template <typename ConsoleMutex>
|
||||
ansicolor_stderr_sink<ConsoleMutex>::ansicolor_stderr_sink(color_mode mode)
|
||||
: ansicolor_sink<ConsoleMutex>(stderr, mode) {}
|
||||
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
||||
// template instantiations
|
||||
template SPDLOG_API class spdlog::sinks::ansicolor_stdout_sink<spdlog::details::console_mutex>;
|
||||
|
@@ -34,8 +34,8 @@ void basic_file_sink<Mutex>::flush_() {
|
||||
file_helper_.flush();
|
||||
}
|
||||
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
||||
// template instantiations
|
||||
template class SPDLOG_API spdlog::sinks::basic_file_sink<std::mutex>;
|
||||
|
@@ -34,7 +34,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;
|
||||
@@ -106,11 +106,12 @@ void rotating_file_sink<Mutex>::rotate_() {
|
||||
if (!rename_file_(src, target)) {
|
||||
// if failed try again after a small delay.
|
||||
// this is a workaround to a windows issue, where very high rotation
|
||||
// rates can cause the rename to fail with permission denied (because of antivirus?).
|
||||
// rates can cause the rename to fail with permission denied (because of
|
||||
// antivirus?).
|
||||
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!
|
||||
file_helper_.reopen(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),
|
||||
@@ -131,8 +132,8 @@ bool rotating_file_sink<Mutex>::rename_file_(const filename_t &src_filename,
|
||||
return details::os::rename(src_filename, target_filename) == 0;
|
||||
}
|
||||
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
||||
// template instantiations
|
||||
template class SPDLOG_API spdlog::sinks::rotating_file_sink<std::mutex>;
|
||||
|
@@ -28,7 +28,7 @@ template <typename Factory>
|
||||
std::shared_ptr<logger> stderr_color_st(const std::string &logger_name, color_mode mode) {
|
||||
return Factory::template create<sinks::stderr_color_sink_st>(logger_name, mode);
|
||||
}
|
||||
} // namespace spdlog
|
||||
} // namespace spdlog
|
||||
|
||||
// template instantiations
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
||||
@@ -47,14 +47,14 @@ template SPDLOG_API std::shared_ptr<spdlog::logger>
|
||||
spdlog::stderr_color_st<spdlog::synchronous_factory>(const std::string &logger_name,
|
||||
color_mode mode);
|
||||
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
||||
spdlog::stdout_color_mt<spdlog::async_factory>(const std::string &logger_name, color_mode mode);
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger> spdlog::stdout_color_mt<spdlog::async_factory>(
|
||||
const std::string &logger_name, color_mode mode);
|
||||
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
||||
spdlog::stdout_color_st<spdlog::async_factory>(const std::string &logger_name, color_mode mode);
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger> spdlog::stdout_color_st<spdlog::async_factory>(
|
||||
const std::string &logger_name, color_mode mode);
|
||||
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
||||
spdlog::stderr_color_mt<spdlog::async_factory>(const std::string &logger_name, color_mode mode);
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger> spdlog::stderr_color_mt<spdlog::async_factory>(
|
||||
const std::string &logger_name, color_mode mode);
|
||||
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
||||
spdlog::stderr_color_st<spdlog::async_factory>(const std::string &logger_name, color_mode mode);
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger> spdlog::stderr_color_st<spdlog::async_factory>(
|
||||
const std::string &logger_name, color_mode mode);
|
||||
|
@@ -10,13 +10,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 {
|
||||
|
||||
@@ -38,7 +38,7 @@ 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>
|
||||
@@ -62,8 +62,8 @@ void stdout_sink_base<ConsoleMutex>::log(const details::log_msg &msg) {
|
||||
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>
|
||||
@@ -95,7 +95,7 @@ template <typename ConsoleMutex>
|
||||
stderr_sink<ConsoleMutex>::stderr_sink()
|
||||
: stdout_sink_base<ConsoleMutex>(stderr) {}
|
||||
|
||||
} // namespace sinks
|
||||
} // namespace sinks
|
||||
|
||||
// factory methods
|
||||
template <typename Factory>
|
||||
@@ -117,7 +117,7 @@ template <typename Factory>
|
||||
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
|
||||
|
||||
// template instantiations for stdout/stderr loggers
|
||||
#include <spdlog/details/console_globals.h>
|
||||
@@ -141,11 +141,11 @@ spdlog::stderr_logger_mt<spdlog::synchronous_factory>(const std::string &logger_
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
||||
spdlog::stderr_logger_st<spdlog::synchronous_factory>(const std::string &logger_name);
|
||||
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
||||
spdlog::stdout_logger_mt<spdlog::async_factory>(const std::string &logger_name);
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
||||
spdlog::stdout_logger_st<spdlog::async_factory>(const std::string &logger_name);
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
||||
spdlog::stderr_logger_mt<spdlog::async_factory>(const std::string &logger_name);
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
||||
spdlog::stderr_logger_st<spdlog::async_factory>(const std::string &logger_name);
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger> spdlog::stdout_logger_mt<spdlog::async_factory>(
|
||||
const std::string &logger_name);
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger> spdlog::stdout_logger_st<spdlog::async_factory>(
|
||||
const std::string &logger_name);
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger> spdlog::stderr_logger_mt<spdlog::async_factory>(
|
||||
const std::string &logger_name);
|
||||
template SPDLOG_API std::shared_ptr<spdlog::logger> spdlog::stderr_logger_st<spdlog::async_factory>(
|
||||
const std::string &logger_name);
|
||||
|
@@ -19,15 +19,15 @@ wincolor_sink<ConsoleMutex>::wincolor_sink(void *out_handle, color_mode mode)
|
||||
set_color_mode_impl(mode);
|
||||
// set level colors
|
||||
colors_.at(level_to_number(level::trace)) =
|
||||
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; // white
|
||||
colors_.at(level_to_number(level::debug)) = FOREGROUND_GREEN | FOREGROUND_BLUE; // cyan
|
||||
colors_.at(level_to_number(level::info)) = FOREGROUND_GREEN; // green
|
||||
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; // white
|
||||
colors_.at(level_to_number(level::debug)) = FOREGROUND_GREEN | FOREGROUND_BLUE; // cyan
|
||||
colors_.at(level_to_number(level::info)) = FOREGROUND_GREEN; // green
|
||||
colors_.at(level_to_number(level::warn)) =
|
||||
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; // intense yellow
|
||||
colors_.at(level_to_number(level::err)) = FOREGROUND_RED | FOREGROUND_INTENSITY; // intense red
|
||||
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; // intense yellow
|
||||
colors_.at(level_to_number(level::err)) = FOREGROUND_RED | FOREGROUND_INTENSITY; // intense red
|
||||
colors_.at(level_to_number(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_.at(level_to_number(level::off)) = 0;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ void 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);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ std::uint16_t wincolor_sink<ConsoleMutex>::set_foreground_color_(std::uint16_t a
|
||||
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
|
||||
@@ -153,8 +153,8 @@ wincolor_stdout_sink<ConsoleMutex>::wincolor_stdout_sink(color_mode mode)
|
||||
template <typename ConsoleMutex>
|
||||
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
|
||||
|
||||
// template instantiations
|
||||
template class SPDLOG_API spdlog::sinks::wincolor_sink<spdlog::details::console_mutex>;
|
||||
@@ -164,4 +164,4 @@ template class SPDLOG_API spdlog::sinks::wincolor_stdout_sink<spdlog::details::c
|
||||
template class SPDLOG_API spdlog::sinks::wincolor_stderr_sink<spdlog::details::console_mutex>;
|
||||
template class SPDLOG_API spdlog::sinks::wincolor_stderr_sink<spdlog::details::console_nullmutex>;
|
||||
|
||||
#endif // _WIN32
|
||||
#endif // _WIN32
|
||||
|
Reference in New Issue
Block a user