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