c++ easylogging 使用示例

easylogging++是一个轻量型简单的日志库,使用示例如下所示:

#include "easylogging++.h"

INITIALIZE_EASYLOGGINGPP

TIMED_SCOPE(appTimer, "myapplication");

int main() {

el::Configurations conf;

conf.set(el::Level::Global, el::ConfigurationType::Filename, "myeasylog.log");

conf.set(el::Level::Global, el::ConfigurationType::Enabled, "true");

conf.set(el::Level::Global,

el::ConfigurationType::Format,

"%datetime %level [%func] [%user@%host] [%file:%line] %msg"); // 包含文件名和行号信息

el::Loggers::reconfigureAllLoggers(conf);

LOG(INFO) << "Starting...";

el::Loggers::removeFlag(el::LoggingFlag::AllowVerboseIfModuleNotSpecified);

{

//TIMED_SCOPE(tmr, "write-simple");

LOG(INFO) << "Test " << FILE ;

}

LOG(INFO) << "Test verbose";

//system("pause");

}

运行结果示例:

相关推荐
SoveTingღ20 小时前
【问题解析】我的客户端与服务器交互无响应了?
服务器·c++·qt·tcp
温宇飞21 小时前
内存异常
c++
挖矿大亨1 天前
C++中深拷贝与浅拷贝的原理
开发语言·c++·算法
Bruce_kaizy1 天前
c++图论——生成树之Kruskal&Prim算法
c++·算法·图论
雾岛听蓝1 天前
C++:模拟实现string类
开发语言·c++
XFF不秃头1 天前
力扣刷题笔记-合并区间
c++·笔记·算法·leetcode
编程之路,妙趣横生1 天前
STL(七) unordered_set 与 unordered_map 基本用法 + 模拟实现
c++
寂柒1 天前
c++--
c++
wregjru1 天前
【读书笔记】Effective C++ 条款3:尽可能使用const
开发语言·c++
历程里程碑1 天前
滑动窗口秒解LeetCode字母异位词
java·c语言·开发语言·数据结构·c++·算法·leetcode