Commit 6cc7e738 authored by gabime's avatar gabime

astyle

parent 40fc5bec
...@@ -57,14 +57,14 @@ class async_log_helper ...@@ -57,14 +57,14 @@ class async_log_helper
~async_msg() = default; ~async_msg() = default;
async_msg(async_msg&& other) SPDLOG_NOEXCEPT: async_msg(async_msg&& other) SPDLOG_NOEXCEPT:
logger_name(std::move(other.logger_name)), logger_name(std::move(other.logger_name)),
level(std::move(other.level)), level(std::move(other.level)),
time(std::move(other.time)), time(std::move(other.time)),
thread_id(other.thread_id), thread_id(other.thread_id),
txt(std::move(other.txt)), txt(std::move(other.txt)),
msg_type(std::move(other.msg_type)), msg_type(std::move(other.msg_type)),
msg_id(other.msg_id) msg_id(other.msg_id)
{} {}
async_msg(async_msg_type m_type): async_msg(async_msg_type m_type):
......
...@@ -19,10 +19,10 @@ namespace details ...@@ -19,10 +19,10 @@ namespace details
struct log_msg struct log_msg
{ {
log_msg() = default; log_msg() = default;
log_msg(const std::string *loggers_name, level::level_enum lvl) : log_msg(const std::string *loggers_name, level::level_enum lvl) :
logger_name(loggers_name), logger_name(loggers_name),
level(lvl), level(lvl),
msg_id(0) msg_id(0)
{ {
#ifndef SPDLOG_NO_DATETIME #ifndef SPDLOG_NO_DATETIME
time = os::now(); time = os::now();
......
...@@ -38,7 +38,10 @@ inline spdlog::logger::logger(const std::string& logger_name, sinks_init_list si ...@@ -38,7 +38,10 @@ inline spdlog::logger::logger(const std::string& logger_name, sinks_init_list si
// ctor with single sink // ctor with single sink
inline spdlog::logger::logger(const std::string& logger_name, spdlog::sink_ptr single_sink): inline spdlog::logger::logger(const std::string& logger_name, spdlog::sink_ptr single_sink):
logger(logger_name, { single_sink }) logger(logger_name,
{
single_sink
})
{} {}
......
This diff is collapsed.
...@@ -149,13 +149,13 @@ inline std::shared_ptr<spdlog::logger> spdlog::stdout_color_st(const std::string ...@@ -149,13 +149,13 @@ inline std::shared_ptr<spdlog::logger> spdlog::stdout_color_st(const std::string
inline std::shared_ptr<spdlog::logger> spdlog::stderr_color_mt(const std::string& logger_name) inline std::shared_ptr<spdlog::logger> spdlog::stderr_color_mt(const std::string& logger_name)
{ {
auto sink = std::make_shared<spdlog::sinks::ansicolor_stderr_sink_mt>(); auto sink = std::make_shared<spdlog::sinks::ansicolor_stderr_sink_mt>();
return spdlog::details::registry::instance().create(logger_name, sink); return spdlog::details::registry::instance().create(logger_name, sink);
} }
inline std::shared_ptr<spdlog::logger> spdlog::stderr_color_st(const std::string& logger_name) inline std::shared_ptr<spdlog::logger> spdlog::stderr_color_st(const std::string& logger_name)
{ {
auto sink = std::make_shared<spdlog::sinks::ansicolor_stderr_sink_st>(); auto sink = std::make_shared<spdlog::sinks::ansicolor_stderr_sink_st>();
return spdlog::details::registry::instance().create(logger_name, sink); return spdlog::details::registry::instance().create(logger_name, sink);
} }
#endif #endif
......
...@@ -14,85 +14,85 @@ ...@@ -14,85 +14,85 @@
namespace spdlog namespace spdlog
{ {
namespace sinks namespace sinks
{ {
/** /**
* @brief The ansi_color_sink is a decorator around another sink and prefixes * @brief The ansi_color_sink is a decorator around another sink and prefixes
* the output with an ANSI escape sequence color code depending on the severity * the output with an ANSI escape sequence color code depending on the severity
* of the message. * of the message.
*/ */
template <class Mutex> template <class Mutex>
class ansicolor_sink SPDLOG_FINAL: public base_sink<Mutex> class ansicolor_sink SPDLOG_FINAL: public base_sink<Mutex>
{ {
public: public:
ansicolor_sink(FILE* file): target_file_(file) ansicolor_sink(FILE* file): target_file_(file)
{ {
should_do_colors_ = details::os::in_terminal(file) && details::os::is_color_terminal(); should_do_colors_ = details::os::in_terminal(file) && details::os::is_color_terminal();
colors_[level::trace] = "\033[36m"; // cyan; colors_[level::trace] = "\033[36m"; // cyan;
colors_[level::debug] = "\033[36m"; // cyan; colors_[level::debug] = "\033[36m"; // cyan;
colors_[level::info] = "\033[1m";// bold; colors_[level::info] = "\033[1m";// bold;
colors_[level::warn] = "\033[33m\033[1m"; // yellow_bold; colors_[level::warn] = "\033[33m\033[1m"; // yellow_bold;
colors_[level::err] = "\033[31m\033[1m"; // red_bold; colors_[level::err] = "\033[31m\033[1m"; // red_bold;
colors_[level::critical] = "\033[1m\033[41m"; // bold_red_bg; colors_[level::critical] = "\033[1m\033[41m"; // bold_red_bg;
colors_[level::off] = "\033[00m"; //reset; colors_[level::off] = "\033[00m"; //reset;
} }
virtual ~ansicolor_sink() virtual ~ansicolor_sink()
{ {
flush(); flush();
} }
void flush() override void flush() override
{ {
fflush(target_file_); fflush(target_file_);
} }
protected: protected:
virtual void _sink_it(const details::log_msg& msg) override virtual void _sink_it(const details::log_msg& msg) override
{ {
// Wrap the originally formatted message in color codes. // Wrap the originally formatted message in color codes.
// If color is not supported in the terminal, log as is instead. // If color is not supported in the terminal, log as is instead.
if (should_do_colors_) if (should_do_colors_)
{ {
const std::string& prefix = colors_[msg.level]; const std::string& prefix = colors_[msg.level];
const std::string& reset = colors_[level::off]; const std::string& reset = colors_[level::off];
fwrite(prefix.c_str(), sizeof(char), prefix.size(), target_file_); fwrite(prefix.c_str(), sizeof(char), prefix.size(), target_file_);
fwrite(msg.formatted.data(), sizeof(char), msg.formatted.size(), target_file_); fwrite(msg.formatted.data(), sizeof(char), msg.formatted.size(), target_file_);
fwrite(reset.c_str(), sizeof(char), reset.size(), target_file_); fwrite(reset.c_str(), sizeof(char), reset.size(), target_file_);
} }
else else
{ {
fwrite(msg.formatted.data(), sizeof(char), msg.formatted.size(), target_file_); fwrite(msg.formatted.data(), sizeof(char), msg.formatted.size(), target_file_);
} }
} }
FILE* target_file_; FILE* target_file_;
bool should_do_colors_; bool should_do_colors_;
std::map<level::level_enum, std::string> colors_; std::map<level::level_enum, std::string> colors_;
}; };
template<class Mutex> template<class Mutex>
class ansicolor_stdout_sink: public ansicolor_sink<Mutex> class ansicolor_stdout_sink: public ansicolor_sink<Mutex>
{ {
public: public:
ansicolor_stdout_sink(): ansicolor_sink<Mutex>(stdout) ansicolor_stdout_sink(): ansicolor_sink<Mutex>(stdout)
{} {}
}; };
template<class Mutex> template<class Mutex>
class ansicolor_stderr_sink: public ansicolor_sink<Mutex> class ansicolor_stderr_sink: public ansicolor_sink<Mutex>
{ {
public: public:
ansicolor_stderr_sink(): ansicolor_sink<Mutex>(stderr) ansicolor_stderr_sink(): ansicolor_sink<Mutex>(stderr)
{} {}
}; };
typedef ansicolor_stdout_sink<std::mutex> ansicolor_stdout_sink_mt; typedef ansicolor_stdout_sink<std::mutex> ansicolor_stdout_sink_mt;
typedef ansicolor_stdout_sink<details::null_mutex> ansicolor_stdout_sink_st; typedef ansicolor_stdout_sink<details::null_mutex> ansicolor_stdout_sink_st;
typedef ansicolor_stderr_sink<std::mutex> ansicolor_stderr_sink_mt; typedef ansicolor_stderr_sink<std::mutex> ansicolor_stderr_sink_mt;
typedef ansicolor_stderr_sink<details::null_mutex> ansicolor_stderr_sink_st; typedef ansicolor_stderr_sink<details::null_mutex> ansicolor_stderr_sink_st;
} // namespace sinks } // namespace sinks
} // namespace spdlog } // namespace spdlog
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Uncomment to enable message counting feature. Adds %i logger pattern that // Uncomment to enable message counting feature. Adds %i logger pattern that
// prints log message sequence id. // prints log message sequence id.
// //
// #define SPDLOG_ENABLE_MESSAGE_COUNTER // #define SPDLOG_ENABLE_MESSAGE_COUNTER
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment