Code formatting

This commit is contained in:
gabime 2018-07-07 13:22:43 +03:00
parent a9a7309001
commit 39c6eb752a
7 changed files with 18 additions and 36 deletions

View File

@ -7,10 +7,10 @@
// bench.cpp : spdlog benchmarks
//
#include "spdlog/async.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/daily_file_sink.h"
#include "spdlog/sinks/null_sink.h"
#include "spdlog/sinks/rotating_file_sink.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/spdlog.h"
#include "utils.h"
#include <atomic>
@ -122,7 +122,7 @@ void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count
for (int t = 0; t < thread_count; ++t)
{
threads.push_back(std::thread([&]() {
for (int j = 0; j < howmany/thread_count; j++)
for (int j = 0; j < howmany / thread_count; j++)
{
log->info("Hello logger: msg number {}", j);
}
@ -134,7 +134,7 @@ void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count
t.join();
};
auto delta = high_resolution_clock::now() - start;
auto delta = high_resolution_clock::now() - start;
auto delta_d = duration_cast<duration<double>>(delta).count();
cout << "Elapsed: " << delta_d << "\t" << format(int(howmany / delta_d)) << "/sec" << endl;
}

View File

@ -7,7 +7,6 @@
//
//
#include <iostream>
void stdout_example();
@ -42,7 +41,6 @@ int main(int, char *[])
// custom error handler
err_handler_example();
// apply some function on all registered loggers
spdlog::apply_all([&](std::shared_ptr<spdlog::logger> l) { l->info("End of example."); });
@ -57,7 +55,6 @@ int main(int, char *[])
}
}
#include "spdlog/sinks/stdout_color_sinks.h" // or "/sinks/stdout_sinks.h" if no colors needed
void stdout_example()
@ -68,7 +65,7 @@ void stdout_example()
console->error("Some error message with arg: {}", 1);
auto err_logger = spdlog::stderr_color_mt("error_logger");
err_logger ->error("Some error message");
err_logger->error("Some error message");
// Formatting examples
console->warn("Easy padding in numbers like {:08d}", 12);
console->critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
@ -84,21 +81,16 @@ void stdout_example()
console->set_level(spdlog::level::trace); // Set specific logger's log level
console->debug("This message should be displayed..");
// Customize msg format for all loggers
spdlog::set_pattern("[%H:%M:%S %z] [%^---%L---%$] [thread %t] %v");
console->info("This an info message with custom format");
// Compile time log levels
// define SPDLOG_DEBUG_ON or SPDLOG_TRACE_ON
SPDLOG_TRACE(console, "Enabled only #ifdef SPDLOG_TRACE_ON..{} ,{}", 1, 3.23);
SPDLOG_DEBUG(console, "Enabled only #ifdef SPDLOG_DEBUG_ON.. {} ,{}", 1, 3.23);
}
#include "spdlog/sinks/basic_file_sink.h"
void basic_example()
{
@ -118,10 +110,8 @@ void daily_example()
{
// Create a daily logger - a new file is created every day on 2:30am
auto daily_logger = spdlog::daily_logger_mt("daily_logger", "logs/daily.txt", 2, 30);
}
#include "spdlog/async.h"
void async_example()
{
@ -137,8 +127,6 @@ void async_example()
}
}
// user defined types logging by implementing operator<<
#include "spdlog/fmt/ostr.h" // must be included
struct my_type
@ -151,7 +139,6 @@ struct my_type
}
};
void user_defined_example()
{
spdlog::get("console")->info("user defined type: {}", my_type{14});
@ -167,7 +154,6 @@ void err_handler_example()
spdlog::get("console")->info("some invalid message to trigger an error {}{}{}{}", 3);
}
// syslog example (linux/osx/freebsd)
#ifndef _WIN32
#include "spdlog/sinks/syslog_sink.h"

View File

@ -122,7 +122,7 @@ inline void pad6(size_t n, fmt::memory_buffer &dest)
dest.push_back('0');
dest.push_back('0');
dest.push_back('0');
}
}
append_int(n, dest);
}

View File

@ -26,8 +26,6 @@ public:
file_helper_.open(filename, truncate);
}
protected:
void sink_it_(const details::log_msg &, const fmt::memory_buffer &formatted) override
{

View File

@ -18,7 +18,7 @@
namespace spdlog {
namespace sinks {
template <typename Mutex>
template<typename Mutex>
class dist_sink : public sink
{
public:
@ -60,7 +60,6 @@ public:
private:
Mutex mutex_;
std::vector<std::shared_ptr<sink>> sinks_;
};
using dist_sink_mt = dist_sink<std::mutex>;

View File

@ -18,17 +18,17 @@ public:
: formatter_(std::unique_ptr<spdlog::formatter>(new pattern_formatter("%+")))
{
}
//
// explicit sink(const std::string &formatter_pattern)
// : formatter_(std::unique_ptr<spdlog::formatter>(new pattern_formatter(formatter_pattern)))
// {
// }
//
// // sink with custom formatter
// explicit sink(std::unique_ptr<spdlog::formatter> sink_formatter)
// : formatter_(std::move(sink_formatter))
// {
// }
//
// explicit sink(const std::string &formatter_pattern)
// : formatter_(std::unique_ptr<spdlog::formatter>(new pattern_formatter(formatter_pattern)))
// {
// }
//
// // sink with custom formatter
// explicit sink(std::unique_ptr<spdlog::formatter> sink_formatter)
// : formatter_(std::move(sink_formatter))
// {
// }
virtual ~sink() = default;
@ -60,7 +60,6 @@ public:
formatter_ = std::move(sink_formatter);
}
protected:
level_t level_{level::trace};
std::unique_ptr<spdlog::formatter> formatter_;

View File

@ -13,10 +13,10 @@
#define SPDLOG_DEBUG_ON
#include "spdlog/async.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/daily_file_sink.h"
#include "spdlog/sinks/null_sink.h"
#include "spdlog/sinks/ostream_sink.h"
#include "spdlog/sinks/rotating_file_sink.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/stdout_color_sinks.h"
#include "spdlog/spdlog.h"