|
|
@ -23,7 +23,7 @@ void init()
|
|
|
|
keywords::file_name = "logs/boost-sample_%N.log", /*< file name pattern >*/
|
|
|
|
keywords::file_name = "logs/boost-sample_%N.log", /*< file name pattern >*/
|
|
|
|
keywords::rotation_size = 10 * 1024 * 1024, /*< rotate files every 10 MiB... >*/
|
|
|
|
keywords::rotation_size = 10 * 1024 * 1024, /*< rotate files every 10 MiB... >*/
|
|
|
|
keywords::auto_flush = false,
|
|
|
|
keywords::auto_flush = false,
|
|
|
|
keywords::format = "[%TimeStamp%]: %Message%"
|
|
|
|
keywords::format = "[%TimeStamp%]: %Message%"
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
logging::core::get()->set_filter
|
|
|
|
logging::core::get()->set_filter
|
|
|
@ -38,24 +38,24 @@ using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int thread_count = 10;
|
|
|
|
int thread_count = 10;
|
|
|
|
if(argc > 1)
|
|
|
|
if(argc > 1)
|
|
|
|
thread_count = atoi(argv[1]);
|
|
|
|
thread_count = atoi(argv[1]);
|
|
|
|
|
|
|
|
|
|
|
|
int howmany = 1000000;
|
|
|
|
int howmany = 1000000;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init();
|
|
|
|
init();
|
|
|
|
logging::add_common_attributes();
|
|
|
|
logging::add_common_attributes();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using namespace logging::trivial;
|
|
|
|
using namespace logging::trivial;
|
|
|
|
|
|
|
|
|
|
|
|
src::severity_logger_mt< severity_level > lg;
|
|
|
|
src::severity_logger_mt< severity_level > lg;
|
|
|
|
|
|
|
|
|
|
|
|
std::atomic<int > msg_counter {0};
|
|
|
|
std::atomic<int > msg_counter {0};
|
|
|
|
vector<thread> threads;
|
|
|
|
vector<thread> threads;
|
|
|
|
|
|
|
|
|
|
|
|
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([&]()
|
|
|
@ -64,7 +64,7 @@ int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int counter = ++msg_counter;
|
|
|
|
int counter = ++msg_counter;
|
|
|
|
if (counter > howmany) break;
|
|
|
|
if (counter > howmany) break;
|
|
|
|
BOOST_LOG_SEV(lg, info) << "Boost logger message #" << counter;
|
|
|
|
BOOST_LOG_SEV(lg, info) << "Boost logger message #" << counter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -74,7 +74,7 @@ int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
t.join();
|
|
|
|
t.join();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|