使用easylogging++进行日志输出

#include 
#include 
//支持多线程
#define ELPP_THREAD_SAFE
#include "easylogging++.h"
INITIALIZE_EASYLOGGINGPP
using namespace std;

int main(int argc, char* argv[])
{
    std::cout << "test openh264" << std::endl;
    int nPos = 1024*1024*2;

    el::Configurations defaultConf;
    defaultConf.setToDefault();
    //设置最大文件大小
    defaultConf.setGlobally(el::ConfigurationType::MaxLogFileSize, "2097152");
    //是否写入文件
    defaultConf.setGlobally(el::ConfigurationType::ToFile, "true");
    //是否输出控制台
    defaultConf.setGlobally(el::ConfigurationType::ToStandardOutput, "false");
    //设置配置文件
    el::Loggers::reconfigureLogger("default", defaultConf);
    
    /// 防止Fatal级别日志中断程序
    el::Loggers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog);
    
    /// 选择划分级别的日志    
    el::Loggers::addFlag(el::LoggingFlag::HierarchicalLogging);

    /// 设置级别门阀值,修改参数可以控制日志输出
    el::Loggers::setLoggingLevel(el::Level::Global);

    LOG(INFO) << "Log using default file" << nPos;

    LOG(TRACE)<< "Log using default file" << nPos;
    LOG(DEBUG)<< "Log using default file" << nPos;
    LOG(FATAL)<< "Log using default file" << nPos;
    LOG(ERROR)<< "Log using default file" << nPos;
    LOG(WARNING)<< "Log using default file" << nPos;
    LOG(INFO)<< "Log using default file" << nPos;
    VLOG(0)<< "Log using default file" << nPos;
    return 0;
}

 

你可能感兴趣的:(C++探究,OpenCV,图片合成,日志库)