Commit c97c025a authored by gabime's avatar gabime

clang-format

parent c55336e7
...@@ -116,7 +116,7 @@ int main(int argc, char *argv[]) ...@@ -116,7 +116,7 @@ int main(int argc, char *argv[])
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(filename, true); auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(filename, true);
auto logger = std::make_shared<async_logger>("async_logger", std::move(file_sink), std::move(tp), async_overflow_policy::block); auto logger = std::make_shared<async_logger>("async_logger", std::move(file_sink), std::move(tp), async_overflow_policy::block);
bench_mt(howmany, std::move(logger), threads); bench_mt(howmany, std::move(logger), threads);
//verify_file(filename, howmany); // verify_file(filename, howmany);
} }
spdlog::info(""); spdlog::info("");
......
...@@ -45,7 +45,7 @@ int main(int, char *[]) ...@@ -45,7 +45,7 @@ int main(int, char *[])
// Loggers can store in a ring buffer all messages (including debug/trace) for later inspection. // Loggers can store in a ring buffer all messages (including debug/trace) for later inspection.
// When needed, call dump_backtrace() to see what happened: // When needed, call dump_backtrace() to see what happened:
spdlog::enable_backtrace(10); // create ring buffer with capacity of 10 messages spdlog::enable_backtrace(10); // create ring buffer with capacity of 10 messages
for(int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
{ {
spdlog::debug("Backtrace message {}", i); // not logged.. spdlog::debug("Backtrace message {}", i); // not logged..
} }
......
...@@ -83,4 +83,3 @@ SPDLOG_INLINE void spdlog::async_logger::backend_flush_() ...@@ -83,4 +83,3 @@ SPDLOG_INLINE void spdlog::async_logger::backend_flush_()
SPDLOG_LOGGER_CATCH() SPDLOG_LOGGER_CATCH()
} }
} }
...@@ -49,7 +49,6 @@ public: ...@@ -49,7 +49,6 @@ public:
async_logger(std::string logger_name, sink_ptr single_sink, std::weak_ptr<details::thread_pool> tp, async_logger(std::string logger_name, sink_ptr single_sink, std::weak_ptr<details::thread_pool> tp,
async_overflow_policy overflow_policy = async_overflow_policy::block); async_overflow_policy overflow_policy = async_overflow_policy::block);
protected: protected:
void sink_it_(const details::log_msg &msg) override; void sink_it_(const details::log_msg &msg) override;
void flush_() override; void flush_() override;
......
...@@ -22,11 +22,13 @@ class backtracer ...@@ -22,11 +22,13 @@ class backtracer
public: public:
explicit backtracer(size_t n_messages) explicit backtracer(size_t n_messages)
: n_messages_{n_messages}, messages_{n_messages} : n_messages_{n_messages}
, messages_{n_messages}
{} {}
backtracer(const backtracer &other): backtracer(const backtracer &other)
n_messages_{other.n_messages_}, messages_{other.messages_} : n_messages_{other.n_messages_}
, messages_{other.messages_}
{} {}
size_t n_messages() const size_t n_messages() const
......
...@@ -23,7 +23,7 @@ SPDLOG_INLINE logger::logger(const logger &other) ...@@ -23,7 +23,7 @@ SPDLOG_INLINE logger::logger(const logger &other)
, flush_level_(other.flush_level_.load(std::memory_order_relaxed)) , flush_level_(other.flush_level_.load(std::memory_order_relaxed))
, custom_err_handler_(other.custom_err_handler_) , custom_err_handler_(other.custom_err_handler_)
{ {
if(other.tracer_) if (other.tracer_)
{ {
tracer_ = std::make_shared<details::backtracer>(*other.tracer_); tracer_ = std::make_shared<details::backtracer>(*other.tracer_);
} }
......
...@@ -356,7 +356,6 @@ public: ...@@ -356,7 +356,6 @@ public:
// error handler // error handler
void set_error_handler(err_handler); void set_error_handler(err_handler);
protected: protected:
std::string name_; std::string name_;
std::vector<sink_ptr> sinks_; std::vector<sink_ptr> sinks_;
......
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
#include "test_sink.h" #include "test_sink.h"
#include "spdlog/async.h" #include "spdlog/async.h"
TEST_CASE("bactrace1", "[bactrace]") TEST_CASE("bactrace1", "[bactrace]")
{ {
...@@ -17,14 +14,14 @@ TEST_CASE("bactrace1", "[bactrace]") ...@@ -17,14 +14,14 @@ TEST_CASE("bactrace1", "[bactrace]")
logger.enable_backtrace(backtrace_size); logger.enable_backtrace(backtrace_size);
logger.info("info message"); logger.info("info message");
for(int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
logger.debug("debug message {}", i); logger.debug("debug message {}", i);
REQUIRE(test_sink->lines().size() == 1); REQUIRE(test_sink->lines().size() == 1);
REQUIRE(test_sink->lines()[0] == "info message"); REQUIRE(test_sink->lines()[0] == "info message");
logger.dump_backtrace(); logger.dump_backtrace();
REQUIRE(test_sink->lines().size() == backtrace_size +3); REQUIRE(test_sink->lines().size() == backtrace_size + 3);
REQUIRE(test_sink->lines()[1] == "****************** Backtrace Start ******************"); REQUIRE(test_sink->lines()[1] == "****************** Backtrace Start ******************");
REQUIRE(test_sink->lines()[2] == "debug message 95"); REQUIRE(test_sink->lines()[2] == "debug message 95");
REQUIRE(test_sink->lines()[3] == "debug message 96"); REQUIRE(test_sink->lines()[3] == "debug message 96");
...@@ -34,7 +31,6 @@ TEST_CASE("bactrace1", "[bactrace]") ...@@ -34,7 +31,6 @@ TEST_CASE("bactrace1", "[bactrace]")
REQUIRE(test_sink->lines()[7] == "****************** Backtrace End ********************"); REQUIRE(test_sink->lines()[7] == "****************** Backtrace End ********************");
} }
TEST_CASE("bactrace-async", "[bactrace]") TEST_CASE("bactrace-async", "[bactrace]")
{ {
using spdlog::sinks::test_sink_mt; using spdlog::sinks::test_sink_mt;
...@@ -49,7 +45,7 @@ TEST_CASE("bactrace-async", "[bactrace]") ...@@ -49,7 +45,7 @@ TEST_CASE("bactrace-async", "[bactrace]")
logger->enable_backtrace(backtrace_size); logger->enable_backtrace(backtrace_size);
logger->info("info message"); logger->info("info message");
for(int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
logger->debug("debug message {}", i); logger->debug("debug message {}", i);
sleep_for_millis(10); sleep_for_millis(10);
...@@ -58,7 +54,7 @@ TEST_CASE("bactrace-async", "[bactrace]") ...@@ -58,7 +54,7 @@ TEST_CASE("bactrace-async", "[bactrace]")
logger->dump_backtrace(); logger->dump_backtrace();
sleep_for_millis(100); // give time for the async dump to complete sleep_for_millis(100); // give time for the async dump to complete
REQUIRE(test_sink->lines().size() == backtrace_size +3); REQUIRE(test_sink->lines().size() == backtrace_size + 3);
REQUIRE(test_sink->lines()[1] == "****************** Backtrace Start ******************"); REQUIRE(test_sink->lines()[1] == "****************** Backtrace Start ******************");
REQUIRE(test_sink->lines()[2] == "debug message 95"); REQUIRE(test_sink->lines()[2] == "debug message 95");
REQUIRE(test_sink->lines()[3] == "debug message 96"); REQUIRE(test_sink->lines()[3] == "debug message 96");
...@@ -67,4 +63,3 @@ TEST_CASE("bactrace-async", "[bactrace]") ...@@ -67,4 +63,3 @@ TEST_CASE("bactrace-async", "[bactrace]")
REQUIRE(test_sink->lines()[6] == "debug message 99"); REQUIRE(test_sink->lines()[6] == "debug message 99");
REQUIRE(test_sink->lines()[7] == "****************** Backtrace End ********************"); REQUIRE(test_sink->lines()[7] == "****************** Backtrace End ********************");
} }
...@@ -19,6 +19,7 @@ template<class Mutex> ...@@ -19,6 +19,7 @@ template<class Mutex>
class test_sink : public base_sink<Mutex> class test_sink : public base_sink<Mutex>
{ {
const size_t lines_to_save = 100; const size_t lines_to_save = 100;
public: public:
size_t msg_counter() size_t msg_counter()
{ {
...@@ -45,7 +46,6 @@ public: ...@@ -45,7 +46,6 @@ public:
return lines_; return lines_;
} }
protected: protected:
void sink_it_(const details::log_msg &msg) override void sink_it_(const details::log_msg &msg) override
{ {
...@@ -53,9 +53,9 @@ protected: ...@@ -53,9 +53,9 @@ protected:
base_sink<Mutex>::formatter_->format(msg, formatted); base_sink<Mutex>::formatter_->format(msg, formatted);
// save the line without the eol // save the line without the eol
auto eol_len = strlen(details::os::default_eol); auto eol_len = strlen(details::os::default_eol);
if(lines_.size() < lines_to_save) if (lines_.size() < lines_to_save)
{ {
lines_.emplace_back(formatted.begin(), formatted.end()-eol_len); lines_.emplace_back(formatted.begin(), formatted.end() - eol_len);
} }
msg_counter_++; msg_counter_++;
std::this_thread::sleep_for(delay_); std::this_thread::sleep_for(delay_);
......
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