mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 01:51:38 +08:00
minor fixes
This commit is contained in:
parent
1c4be7fb88
commit
900295611a
@ -18,16 +18,11 @@ using namespace utils;
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
if(argc || argv) {};
|
||||
const unsigned int howmany = argc <= 1 ? 1000 :atoi(argv[1]);
|
||||
const unsigned int howmany = argc <= 1 ? 1000:atoi(argv[1]);
|
||||
|
||||
auto fsink = std::make_shared<sinks::rotating_file_sink>("log", "txt", 1024*1024*50 , 5, 0);
|
||||
auto null_sink = std::make_shared<sinks::null_sink>();
|
||||
|
||||
|
||||
logger cout_logger ("cout", {sinks::stdout_sink()});
|
||||
|
||||
logger my_logger ("my_logger", {null_sink});
|
||||
logger my_logger ("my_logger", {sinks::null_sink::get()});
|
||||
|
||||
auto start = system_clock::now();
|
||||
for(unsigned int i = 0; i < howmany ; i++)
|
||||
@ -36,35 +31,11 @@ int main(int argc, char* argv[])
|
||||
|
||||
auto delta = system_clock::now() - start;
|
||||
auto delta_d = duration_cast<duration<double>> (delta).count();
|
||||
cout_logger.info("Total ") << format(howmany);
|
||||
cout_logger.info("Delta ") << format(delta_d);
|
||||
cout_logger.info("Rate: ") << format(howmany/delta_d) << "/sec";
|
||||
|
||||
logger cout_logger ({sinks::stdout_sink()});
|
||||
cout_logger.info("Total:") << format(howmany);
|
||||
cout_logger.info("Delta:") << format(delta_d);
|
||||
cout_logger.info("Rate:") << format(howmany/delta_d) << "/sec";
|
||||
|
||||
return 0;
|
||||
|
||||
/*
|
||||
if(argc !=3) {
|
||||
std::cerr << "Usage: " << argv[0] << " qsize, threads" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
int qsize = atoi(argv[1]);
|
||||
int threads = atoi(argv[2]);
|
||||
|
||||
|
||||
auto null_sink = std::make_shared<sinks::null_sink>();
|
||||
auto stdout_sink = std::make_shared<sinks::stdout_sink>();
|
||||
auto async = std::make_shared<sinks::async_sink>(qsize);
|
||||
auto fsink = std::make_shared<sinks::rotating_file_sink>("log", "txt", 1024*1024*50 , 5, std::chrono::milliseconds(1000));
|
||||
|
||||
async->add_sink(fsink);
|
||||
|
||||
//auto &logger = c11log::get_logger("async");
|
||||
//logger.add_sink(fsink);
|
||||
|
||||
|
||||
|
||||
testlog(threads);
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -19,14 +19,13 @@ class line_logger
|
||||
public:
|
||||
line_logger(logger* callback_logger, level::level_enum msg_level, bool enabled):
|
||||
_callback_logger(callback_logger),
|
||||
_log_msg(),
|
||||
_log_msg(msg_level),
|
||||
_oss(),
|
||||
_enabled(enabled)
|
||||
{
|
||||
if(enabled)
|
||||
{
|
||||
_log_msg.msg_time = log_clock::now();
|
||||
_log_msg.msg_level = msg_level;
|
||||
_log_msg.msg_time = log_clock::now();
|
||||
callback_logger->_formatter->format_header(callback_logger->_logger_name,
|
||||
_log_msg.msg_level,
|
||||
_log_msg.msg_time,
|
||||
|
@ -45,10 +45,17 @@ protected:
|
||||
|
||||
class null_sink:public base_sink
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<null_sink>& get()
|
||||
{
|
||||
static auto inst = std::make_shared<null_sink>();
|
||||
return inst;
|
||||
}
|
||||
protected:
|
||||
void _sink_it(const details::log_msg&) override
|
||||
{
|
||||
}
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ public:
|
||||
console_sink& operator=(const console_sink&) = delete;
|
||||
virtual ~console_sink() = default;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void _sink_it(const details::log_msg& msg) override
|
||||
{
|
||||
@ -42,6 +43,5 @@ inline std::shared_ptr<console_sink>& stderr_sink ()
|
||||
return inst;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user