RLogC++日志程序库

联合创作 · 2023-09-30 00:46

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));
}
浏览 8
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报