C++日志程序庫:RLog
RLog是一個靈活的C++日志程序庫。RLog高度優化了不用實際輸出Log信息的分支,因此RLog可以留在發布產品中,并可以按需開啟輸出。
示例代碼:
// create custom logging channel (part of debug hierarchy) // Any subscriber to 'debug' will also pick up this sub channel, // or it can be subscribed to directly. static RLogChannel *timeChannel = DEF_CHANNEL("debug/timeStamp", Log_Debug); void func(int foo) { // log to the 'debug' channel rDebug("foo = %i", foo); int ans = 6 * 9; if(ans != 42) rWarning("ans = %i, expecting 42", ans); // log to warning channel // log to error channel rError("I'm sorry %s, I can't do that (error code %i)", name, errno); // log to custom channel // Note: time() never gets called unless there are subscribers to this message rLog(timeChannel, "the time is now %i", (int)time(NULL)); }
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!