astyle
This commit is contained in:
parent
1c7b3e4eb2
commit
e8403e17df
@ -32,7 +32,8 @@ int main(int argc, char* argv[])
|
|||||||
int file_size = 30 * 1024 * 1024;
|
int file_size = 30 * 1024 * 1024;
|
||||||
int rotating_files = 5;
|
int rotating_files = 5;
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
|
|
||||||
if(argc > 1)
|
if(argc > 1)
|
||||||
howmany = atoi(argv[1]);
|
howmany = atoi(argv[1]);
|
||||||
@ -49,7 +50,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
auto daily_st = spdlog::daily_logger_st("daily_st", "logs/daily_st", flush_interval);
|
auto daily_st = spdlog::daily_logger_st("daily_st", "logs/daily_st", flush_interval);
|
||||||
bench(howmany, daily_st);
|
bench(howmany, daily_st);
|
||||||
|
|
||||||
bench(howmany, spdlog::create<null_sink_st>("null_st"));
|
bench(howmany, spdlog::create<null_sink_st>("null_st"));
|
||||||
|
|
||||||
cout << "\n*******************************************************************************\n";
|
cout << "\n*******************************************************************************\n";
|
||||||
@ -100,7 +101,8 @@ void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count
|
|||||||
auto start = system_clock::now();
|
auto start = system_clock::now();
|
||||||
for (int t = 0; t < thread_count; ++t)
|
for (int t = 0; t < thread_count; ++t)
|
||||||
{
|
{
|
||||||
threads.push_back(std::thread([&]() {
|
threads.push_back(std::thread([&]()
|
||||||
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
int counter = ++msg_counter;
|
int counter = ++msg_counter;
|
||||||
|
@ -31,10 +31,11 @@ int main(int, char* [])
|
|||||||
spd::set_level(spd::level::WARN);
|
spd::set_level(spd::level::WARN);
|
||||||
console->info("This should not be displayed");
|
console->info("This should not be displayed");
|
||||||
console->warn("This should!");
|
console->warn("This should!");
|
||||||
|
spd::set_level(spd::level::INFO);
|
||||||
|
|
||||||
// Change format pattern to all loggers
|
// Change format pattern to all loggers
|
||||||
spd::set_pattern(" **** %Y-%m-%d %H:%M:%S.%e %l **** %v");
|
spd::set_pattern(" **** %Y-%m-%d %H:%M:%S.%e %l **** %v");
|
||||||
spd::get("console")->warn("This is another message with different format");
|
spd::get("console")->info("This is another message with different format");
|
||||||
}
|
}
|
||||||
catch (const spd::spdlog_ex& ex)
|
catch (const spd::spdlog_ex& ex)
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
namespace spdlog
|
namespace spdlog
|
||||||
{
|
{
|
||||||
class formatter;
|
class formatter;
|
||||||
namespace sinks {
|
namespace sinks
|
||||||
|
{
|
||||||
class sink;
|
class sink;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +46,8 @@ class spdlog_ex : public std::exception
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
spdlog_ex(const std::string& msg) :_msg(msg) {};
|
spdlog_ex(const std::string& msg) :_msg(msg) {};
|
||||||
const char* what() const throw() override {
|
const char* what() const throw() override
|
||||||
|
{
|
||||||
return _msg.c_str();
|
return _msg.c_str();
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
@ -5,10 +5,13 @@
|
|||||||
//Source: http://stackoverflow.com/a/4351484/192001
|
//Source: http://stackoverflow.com/a/4351484/192001
|
||||||
//Modified version to pad zeros according to padding arg
|
//Modified version to pad zeros according to padding arg
|
||||||
|
|
||||||
namespace spdlog {
|
namespace spdlog
|
||||||
namespace details {
|
{
|
||||||
|
namespace details
|
||||||
|
{
|
||||||
|
|
||||||
const char digit_pairs[201] = {
|
const char digit_pairs[201] =
|
||||||
|
{
|
||||||
"00010203040506070809"
|
"00010203040506070809"
|
||||||
"10111213141516171819"
|
"10111213141516171819"
|
||||||
"20212223242526272829"
|
"20212223242526272829"
|
||||||
|
@ -43,7 +43,8 @@ inline spdlog::formatter_ptr spdlog::logger::get_formatter() const
|
|||||||
|
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
inline spdlog::details::line_logger spdlog::logger::log(level::level_enum lvl, const Args&... args) {
|
inline spdlog::details::line_logger spdlog::logger::log(level::level_enum lvl, const Args&... args)
|
||||||
|
{
|
||||||
bool msg_enabled = should_log(lvl);
|
bool msg_enabled = should_log(lvl);
|
||||||
details::line_logger l(this, lvl, msg_enabled);
|
details::line_logger l(this, lvl, msg_enabled);
|
||||||
if (msg_enabled)
|
if (msg_enabled)
|
||||||
@ -52,7 +53,8 @@ inline spdlog::details::line_logger spdlog::logger::log(level::level_enum lvl, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
inline spdlog::details::line_logger spdlog::logger::log(const Args&... args) {
|
inline spdlog::details::line_logger spdlog::logger::log(const Args&... args)
|
||||||
|
{
|
||||||
return log(level::ALWAYS, args...);
|
return log(level::ALWAYS, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
// null, no cost mutex
|
// null, no cost mutex
|
||||||
|
|
||||||
namespace spdlog {
|
namespace spdlog
|
||||||
namespace details {
|
{
|
||||||
|
namespace details
|
||||||
|
{
|
||||||
struct null_mutex
|
struct null_mutex
|
||||||
{
|
{
|
||||||
void lock() {}
|
void lock() {}
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
|
|
||||||
namespace spdlog
|
namespace spdlog
|
||||||
{
|
{
|
||||||
namespace details {
|
namespace details
|
||||||
|
{
|
||||||
class flag_formatter
|
class flag_formatter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -23,7 +24,8 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
// name & level pattern appenders
|
// name & level pattern appenders
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
class name_formatter :public flag_formatter
|
class name_formatter :public flag_formatter
|
||||||
{
|
{
|
||||||
void format(details::log_msg& msg) override
|
void format(details::log_msg& msg) override
|
||||||
@ -425,7 +427,7 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
|
|||||||
{
|
{
|
||||||
switch (flag)
|
switch (flag)
|
||||||
{
|
{
|
||||||
// logger name
|
// logger name
|
||||||
case 'n':
|
case 'n':
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::name_formatter()));
|
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::name_formatter()));
|
||||||
break;
|
break;
|
||||||
|
@ -11,10 +11,13 @@
|
|||||||
#include "../logger.h"
|
#include "../logger.h"
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
namespace spdlog {
|
namespace spdlog
|
||||||
namespace details {
|
{
|
||||||
|
namespace details
|
||||||
|
{
|
||||||
|
|
||||||
class registry {
|
class registry
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<logger> get(const std::string& logger_name)
|
std::shared_ptr<logger> get(const std::string& logger_name)
|
||||||
{
|
{
|
||||||
|
@ -57,9 +57,6 @@ inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_st(const std::strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::create(const std::string& logger_name, spdlog::sinks_init_list sinks)
|
inline std::shared_ptr<spdlog::logger> spdlog::create(const std::string& logger_name, spdlog::sinks_init_list sinks)
|
||||||
{
|
{
|
||||||
return details::registry::instance().create(logger_name, sinks);
|
return details::registry::instance().create(logger_name, sinks);
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
#include "details/log_msg.h"
|
#include "details/log_msg.h"
|
||||||
namespace spdlog
|
namespace spdlog
|
||||||
{
|
{
|
||||||
namespace details {
|
namespace details
|
||||||
|
{
|
||||||
class flag_formatter;
|
class flag_formatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
#include "../details/null_mutex.h"
|
#include "../details/null_mutex.h"
|
||||||
|
|
||||||
|
|
||||||
namespace spdlog {
|
namespace spdlog
|
||||||
namespace sinks {
|
{
|
||||||
|
namespace sinks
|
||||||
|
{
|
||||||
|
|
||||||
template <class Mutex>
|
template <class Mutex>
|
||||||
class null_sink : public base_sink<Mutex>
|
class null_sink : public base_sink<Mutex>
|
||||||
|
Loading…
Reference in New Issue
Block a user