plog日志库(c++)


1、下载plog第三方库,解压后放到D盘根目录

2、VS项目属性中引入

 3、使用方法

#include <plog/Log.h> //先引入第三方
#include <iostream> //后引入标准库

int getUserInput()
{
    LOGD << "getUserInput() called"; // 输出到日志的内容

    std::cout << "Enter a number: ";
    int x{};
    std::cin >> x;
    return x;
}

int main()
{
    plog::init(plog::debug, "Logfile.txt"); // 启动日志
    //plog::init(plog::none, "Logfile.txt"); // 关闭日志,LOGD << 不会再写入任何内容
    LOGD << "main() called"; // 输出到日志的内容

    int x{ getUserInput() };
    std::cout << "You entered: " << x;

    return 0;
}

在项目路径中生成Logfile.txt


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM