有没有一个整洁的方法来输出文本到调试窗格? [英] Is there a neat method to output text to debugging pane?

查看:120
本文介绍了有没有一个整洁的方法来输出文本到调试窗格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在调试时显示一些日志消息。一个选择是使用非常难看的

I would like to display some log messages when debugging. One option is to use the very ugly

#ifdef DEBUG
    std::cout << "I'm in debug mode!\n";
#endif

JUCE 库,有一个很好的宏输出文本到调试窗格

In the JUCE library, there is a nice macro that outputs text to the debugging pane

DBG("I'm in debug mode!")

int x = 4;
DBG(String("x=") + String(x))



喜欢知道在std ::或boost ::

I would like to know if a similarly neat method exists in std:: or boost::

推荐答案

为什么不自己写: / p>

Why not just write your own:

#ifdef DEBUG
#define DBG(x) std::cout << x;
#else
#define DBG(x)
#endif

命名空间

namespace DBG
{
inline void DBG(const char* x)
{
#ifdef DEBUG
    std::cout << x;
#endif
}
}

这篇关于有没有一个整洁的方法来输出文本到调试窗格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆