mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-28 17:19:34 +08:00
support for color formatting
This commit is contained in:
@@ -82,6 +82,5 @@ int main(int argc, char *argv[])
|
||||
std::cout << "Delta = " << deltaf << " seconds" << std::endl;
|
||||
std::cout << "Rate = " << rate << "/sec" << std::endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -11,8 +11,8 @@
|
||||
|
||||
#define ELPP_THREAD_SAFE
|
||||
#define ELPP_EXPERIMENTAL_ASYNC
|
||||
#include "easylogging++.h"
|
||||
#include "easylogging++.cc"
|
||||
#include "easylogging++.h"
|
||||
INITIALIZE_EASYLOGGINGPP
|
||||
|
||||
using namespace std;
|
||||
|
@@ -10,8 +10,8 @@
|
||||
#include <vector>
|
||||
|
||||
#define ELPP_THREAD_SAFE
|
||||
#include "easylogging++.h"
|
||||
#include "easylogging++.cc"
|
||||
#include "easylogging++.h"
|
||||
INITIALIZE_EASYLOGGINGPP
|
||||
|
||||
using namespace std;
|
||||
|
@@ -6,8 +6,8 @@
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
|
||||
#include "easylogging++.h"
|
||||
#include "easylogging++.cc"
|
||||
#include "easylogging++.h"
|
||||
INITIALIZE_EASYLOGGINGPP
|
||||
|
||||
int main(int, char *[])
|
||||
@@ -21,7 +21,7 @@ int main(int, char *[])
|
||||
el::Configurations conf("easyl.conf");
|
||||
el::Loggers::reconfigureLogger("default", conf);
|
||||
|
||||
el::Logger* defaultLogger = el::Loggers::getLogger("default");
|
||||
el::Logger *defaultLogger = el::Loggers::getLogger("default");
|
||||
|
||||
auto start = clock::now();
|
||||
for (int i = 0; i < howmany; ++i)
|
||||
|
@@ -13,7 +13,8 @@
|
||||
#include "g3log/logworker.hpp"
|
||||
|
||||
using namespace std;
|
||||
template <typename T> std::string format(const T &value);
|
||||
template<typename T>
|
||||
std::string format(const T &value);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -27,7 +28,7 @@ int main(int argc, char *argv[])
|
||||
int howmany = 1000000;
|
||||
|
||||
auto worker = g3::LogWorker::createLogWorker();
|
||||
auto handle= worker->addDefaultLogger(argv[0], "logs");
|
||||
auto handle = worker->addDefaultLogger(argv[0], "logs");
|
||||
g3::initializeLogging(worker.get());
|
||||
|
||||
std::atomic<int> msg_counter{0};
|
||||
|
@@ -8,7 +8,6 @@
|
||||
|
||||
#include "glog/logging.h"
|
||||
|
||||
|
||||
int main(int, char *argv[])
|
||||
{
|
||||
using namespace std::chrono;
|
||||
|
@@ -10,17 +10,17 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "log4cplus/logger.h"
|
||||
#include "log4cplus/fileappender.h"
|
||||
#include "log4cplus/layout.h"
|
||||
#include "log4cplus/ndc.h"
|
||||
#include "log4cplus/helpers/loglog.h"
|
||||
#include "log4cplus/helpers/property.h"
|
||||
#include "log4cplus/layout.h"
|
||||
#include "log4cplus/logger.h"
|
||||
#include "log4cplus/loggingmacros.h"
|
||||
#include "log4cplus/ndc.h"
|
||||
|
||||
using namespace log4cplus;
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using clock = steady_clock;
|
||||
@@ -32,13 +32,11 @@ int main(int argc, char * argv[])
|
||||
int howmany = 1000000;
|
||||
|
||||
log4cplus::initialize();
|
||||
SharedFileAppenderPtr append(
|
||||
new FileAppender(LOG4CPLUS_TEXT("logs/log4cplus-bench-mt.log"), std::ios_base::trunc,
|
||||
true, true));
|
||||
SharedFileAppenderPtr append(new FileAppender(LOG4CPLUS_TEXT("logs/log4cplus-bench-mt.log"), std::ios_base::trunc, true, true));
|
||||
append->setName(LOG4CPLUS_TEXT("File"));
|
||||
|
||||
log4cplus::tstring pattern = LOG4CPLUS_TEXT("%d{%Y-%m-%d %H:%M:%S.%Q}: %p - %m %n");
|
||||
append->setLayout( std::auto_ptr<Layout>(new PatternLayout(pattern)) );
|
||||
append->setLayout(std::auto_ptr<Layout>(new PatternLayout(pattern)));
|
||||
append->getloc();
|
||||
Logger::getRoot().addAppender(SharedAppenderPtr(append.get()));
|
||||
|
||||
|
@@ -7,13 +7,13 @@
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
#include "log4cplus/logger.h"
|
||||
#include "log4cplus/fileappender.h"
|
||||
#include "log4cplus/layout.h"
|
||||
#include "log4cplus/ndc.h"
|
||||
#include "log4cplus/helpers/loglog.h"
|
||||
#include "log4cplus/helpers/property.h"
|
||||
#include "log4cplus/layout.h"
|
||||
#include "log4cplus/logger.h"
|
||||
#include "log4cplus/loggingmacros.h"
|
||||
#include "log4cplus/ndc.h"
|
||||
|
||||
using namespace log4cplus;
|
||||
|
||||
@@ -25,13 +25,11 @@ int main(int, char *[])
|
||||
int howmany = 1000000;
|
||||
|
||||
log4cplus::initialize();
|
||||
SharedFileAppenderPtr append(
|
||||
new FileAppender(LOG4CPLUS_TEXT("logs/log4cplus-bench.log"), std::ios_base::trunc,
|
||||
true, true));
|
||||
SharedFileAppenderPtr append(new FileAppender(LOG4CPLUS_TEXT("logs/log4cplus-bench.log"), std::ios_base::trunc, true, true));
|
||||
append->setName(LOG4CPLUS_TEXT("File"));
|
||||
|
||||
log4cplus::tstring pattern = LOG4CPLUS_TEXT("%d{%Y-%m-%d %H:%M:%S.%Q}: %p - %m %n");
|
||||
append->setLayout( std::auto_ptr<Layout>(new PatternLayout(pattern)) );
|
||||
append->setLayout(std::auto_ptr<Layout>(new PatternLayout(pattern)));
|
||||
append->getloc();
|
||||
Logger::getRoot().addAppender(SharedAppenderPtr(append.get()));
|
||||
|
||||
|
@@ -10,15 +10,15 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "log4cpp/Category.hh"
|
||||
#include "log4cpp/Appender.hh"
|
||||
#include "log4cpp/BasicLayout.hh"
|
||||
#include "log4cpp/Category.hh"
|
||||
#include "log4cpp/FileAppender.hh"
|
||||
#include "log4cpp/Layout.hh"
|
||||
#include "log4cpp/BasicLayout.hh"
|
||||
#include "log4cpp/Priority.hh"
|
||||
#include "log4cpp/PatternLayout.hh"
|
||||
#include "log4cpp/Priority.hh"
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using clock = steady_clock;
|
||||
@@ -29,12 +29,12 @@ int main(int argc, char * argv[])
|
||||
|
||||
int howmany = 1000000;
|
||||
|
||||
log4cpp::Appender *appender = new log4cpp::FileAppender("default", "logs/log4cpp-bench-mt.log");
|
||||
log4cpp::Appender *appender = new log4cpp::FileAppender("default", "logs/log4cpp-bench-mt.log");
|
||||
log4cpp::PatternLayout *layout = new log4cpp::PatternLayout();
|
||||
layout->setConversionPattern("%d{%Y-%m-%d %H:%M:%S.%l}: %p - %m %n");
|
||||
appender->setLayout(layout);
|
||||
|
||||
log4cpp::Category& root = log4cpp::Category::getRoot();
|
||||
log4cpp::Category &root = log4cpp::Category::getRoot();
|
||||
root.addAppender(appender);
|
||||
root.setPriority(log4cpp::Priority::INFO);
|
||||
|
||||
|
@@ -7,13 +7,13 @@
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
#include "log4cpp/Category.hh"
|
||||
#include "log4cpp/Appender.hh"
|
||||
#include "log4cpp/BasicLayout.hh"
|
||||
#include "log4cpp/Category.hh"
|
||||
#include "log4cpp/FileAppender.hh"
|
||||
#include "log4cpp/Layout.hh"
|
||||
#include "log4cpp/BasicLayout.hh"
|
||||
#include "log4cpp/Priority.hh"
|
||||
#include "log4cpp/PatternLayout.hh"
|
||||
#include "log4cpp/Priority.hh"
|
||||
|
||||
int main(int, char *[])
|
||||
{
|
||||
@@ -22,12 +22,12 @@ int main(int, char *[])
|
||||
|
||||
int howmany = 1000000;
|
||||
|
||||
log4cpp::Appender *appender = new log4cpp::FileAppender("default", "logs/log4cpp-bench.log");
|
||||
log4cpp::Appender *appender = new log4cpp::FileAppender("default", "logs/log4cpp-bench.log");
|
||||
log4cpp::PatternLayout *layout = new log4cpp::PatternLayout();
|
||||
layout->setConversionPattern("%d{%Y-%m-%d %H:%M:%S.%l}: %p - %m %n");
|
||||
appender->setLayout(layout);
|
||||
|
||||
log4cpp::Category& root = log4cpp::Category::getRoot();
|
||||
log4cpp::Category &root = log4cpp::Category::getRoot();
|
||||
root.addAppender(appender);
|
||||
root.setPriority(log4cpp::Priority::INFO);
|
||||
|
||||
|
@@ -5,15 +5,14 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
#include "P7_Trace.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
using namespace std::chrono;
|
||||
@@ -27,10 +26,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
IP7_Trace::hModule module = NULL;
|
||||
|
||||
//create P7 client object
|
||||
std::unique_ptr<IP7_Client, std::function<void (IP7_Client *)>> client(
|
||||
P7_Create_Client(TM("/P7.Pool=1024 /P7.Sink=FileTxt /P7.Dir=logs/p7-bench-mt")),
|
||||
[&](IP7_Client *ptr){
|
||||
// create P7 client object
|
||||
std::unique_ptr<IP7_Client, std::function<void(IP7_Client *)>> client(
|
||||
P7_Create_Client(TM("/P7.Pool=1024 /P7.Sink=FileTxt /P7.Dir=logs/p7-bench-mt")), [&](IP7_Client *ptr) {
|
||||
if (ptr)
|
||||
ptr->Release();
|
||||
});
|
||||
@@ -41,10 +39,9 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
//create P7 trace object 1
|
||||
std::unique_ptr<IP7_Trace, std::function<void (IP7_Trace *)>> trace(
|
||||
P7_Create_Trace(client.get(), TM("Trace channel 1")),
|
||||
[&](IP7_Trace *ptr){
|
||||
// create P7 trace object 1
|
||||
std::unique_ptr<IP7_Trace, std::function<void(IP7_Trace *)>> trace(
|
||||
P7_Create_Trace(client.get(), TM("Trace channel 1")), [&](IP7_Trace *ptr) {
|
||||
if (ptr)
|
||||
ptr->Release();
|
||||
});
|
||||
@@ -65,7 +62,7 @@ int main(int argc, char *argv[])
|
||||
for (int t = 0; t < thread_count; ++t)
|
||||
{
|
||||
threads.push_back(std::thread([&]() {
|
||||
trace->Register_Thread(TM("Application"), t+1);
|
||||
trace->Register_Thread(TM("Application"), t + 1);
|
||||
while (true)
|
||||
{
|
||||
int counter = ++msg_counter;
|
||||
@@ -73,7 +70,7 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
trace->P7_INFO(module, TM("p7 message #%d: This is some text for your pleasure"), counter);
|
||||
}
|
||||
trace->Register_Thread(TM("Application"), t+1);
|
||||
trace->Register_Thread(TM("Application"), t + 1);
|
||||
}));
|
||||
}
|
||||
|
||||
|
@@ -4,13 +4,12 @@
|
||||
//
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
#include "P7_Trace.h"
|
||||
|
||||
|
||||
int main(int, char *[])
|
||||
{
|
||||
using namespace std::chrono;
|
||||
@@ -20,10 +19,9 @@ int main(int, char *[])
|
||||
|
||||
IP7_Trace::hModule module = NULL;
|
||||
|
||||
//create P7 client object
|
||||
std::unique_ptr<IP7_Client, std::function<void (IP7_Client *)>> client(
|
||||
P7_Create_Client(TM("/P7.Pool=1024 /P7.Sink=FileTxt /P7.Dir=logs/p7-bench")),
|
||||
[&](IP7_Client *ptr){
|
||||
// create P7 client object
|
||||
std::unique_ptr<IP7_Client, std::function<void(IP7_Client *)>> client(
|
||||
P7_Create_Client(TM("/P7.Pool=1024 /P7.Sink=FileTxt /P7.Dir=logs/p7-bench")), [&](IP7_Client *ptr) {
|
||||
if (ptr)
|
||||
ptr->Release();
|
||||
});
|
||||
@@ -34,10 +32,9 @@ int main(int, char *[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
//create P7 trace object 1
|
||||
std::unique_ptr<IP7_Trace, std::function<void (IP7_Trace *)>> trace(
|
||||
P7_Create_Trace(client.get(), TM("Trace channel 1")),
|
||||
[&](IP7_Trace *ptr){
|
||||
// create P7 trace object 1
|
||||
std::unique_ptr<IP7_Trace, std::function<void(IP7_Trace *)>> trace(
|
||||
P7_Create_Trace(client.get(), TM("Trace channel 1")), [&](IP7_Trace *ptr) {
|
||||
if (ptr)
|
||||
ptr->Release();
|
||||
});
|
||||
@@ -55,7 +52,6 @@ int main(int, char *[])
|
||||
for (int i = 0; i < howmany; ++i)
|
||||
trace->P7_INFO(module, TM("p7 message #%d: This is some text for your pleasure"), i);
|
||||
|
||||
|
||||
duration<float> delta = clock::now() - start;
|
||||
float deltaf = delta.count();
|
||||
auto rate = howmany / deltaf;
|
||||
|
@@ -5,8 +5,8 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
@@ -36,7 +36,7 @@ int main(int argc, char *argv[])
|
||||
run = false;
|
||||
}));
|
||||
|
||||
while(run)
|
||||
while (run)
|
||||
{
|
||||
std::atomic<int> msg_counter{0};
|
||||
std::vector<std::thread> threads;
|
||||
@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
|
||||
std::cout << "Threads: " << thread_count << std::endl;
|
||||
std::cout << "Delta = " << std::fixed << deltaf << " seconds" << std::endl;
|
||||
std::cout << "Rate = " << std::fixed << rate << "/sec" << std::endl;
|
||||
} //while
|
||||
} // while
|
||||
|
||||
stoper.join();
|
||||
|
||||
|
@@ -5,8 +5,8 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
|
Reference in New Issue
Block a user