For programmers who have experience in the development, execution log recording program is a necessary thing. By viewing and analyzing log information, not only can effectively help us debugger, and when the program officially released to run, but can help us to quickly and accurately locate the problem. At this age of open source, we do not need to write their own set of log database, open source version has been a lot. Unfortunately, in the current open source C ++ library journal, and not using a dominant share of the, I used before log4cplus and GLog , both libraries are more mature, but also a lot of online tutorials, so always I liked to use these two log database.
Some time ago, I came across on GitHub another open-source C ++ logging library was just a cursory study, the results actually let me put it down, it is Easylogging ++. And log4cplus and glog compared, Easylogging biggest feature is that it is only a ++ header files, and without any external dependencies, which I've never seen a logging library can do so lightweight but also take into account the performance. In addition, Easylogging ++ very simple to use, and also supports the configuration file, provides a powerful ability to custom log format also provides support for third-party libraries, STL containers. Faced with such a cool open source log, how can not learn! ! !
Easylogging ++ project on GitHub open source Address: https://github.com/easylogging/easyloggingpp
Functional characteristics
- Highly configurable
- the speed is very fast
- And the type of security thread
- Cross-platform
- Custom Log mode
- Conditions logs and occasionally log
- Performance Tracking
- Detailed logging
- Interrupt processing
- Auxiliary CHECK macro
- STL log
- Log third-party libraries (such as Qt, boost, wxWidgets)
- Scalability
- Debug Support Function
- System logging
- perror style log
- C ++ style flow operator log
- C language printf-style log
- ……
As of this writing, the latest Easylogging ++ version V9.80, if the compiler does not support C ++ 11, it can not be compiled. For Visual Studio series, it must be VS2012 or later or job. If still in VS2010, VS2008, VS2005 junior partner, consider using EasyLogging ++ V8.91 version. It should be noted that the different versions will vary in use and function support. In particular, all of the records in this series to learn, apply only to Easylogging ++ version V9.80. In addition, all demo code that appears in this series of articles are compiled using Visual Studio 2013 64Bit Windows 7 system under test is.
Quick
As previously mentioned, Easylogging ++ very simple to use, simple to the point? Here we are given an example on GitHub Code:
#include "easylogging++.h" INITIALIZE_EASYLOGGINGPP int main(int argv, char* argc[]) { LOG(INFO) << "My first info log using default logger"; return 0; }
Only a few lines of sample code, the role of each line of code at a glance:
- It contains easylogging ++. H header files
- Use a macro INITIALIZE_EASYLOGGINGPP initialization
- Use macro LOG (INFO) to start logging
#include "easylogging++.h" INITIALIZE_EASYLOGGINGPP int main(int argc, char** argv) { el::Configurations conf("my_log.conf"); el::Loggers::reconfigureAllLoggers(conf); LOG(TRACE) << "***** trace log *****"; LOG(DEBUG) << "***** debug log *****"; LOG(ERROR) << "***** error log *****"; LOG(WARNING) << "***** warning log *****"; LOG(INFO) << "***** info log *****"; system("pause"); return 0; }
See here, I believe for those who previously used a similar log4cplus small partners such as logs or glog library, in fact, has been fully started using Easylogging ++, and the rest are some of the details or ++ extensions of Easylogging Features, these It will gradually be recorded later in the study. If, like me, you have seen and liked Easylogging ++ friends, let us work together to understand Easylogging ++ and apply it into the actual development of it.
Reference website: https://blog.csdn.net/xie1xiao1jun/article/details/54572803