gpt4 book ai didi

c++ - 如何从源代码中禁用 std::clog 日志记录?

转载 作者:可可西里 更新时间:2023-11-01 18:29:11 24 4
gpt4 key购买 nike

在开发代码时,我有很多控制台日志记录 (std::clog) 和一些控制台输出 (std::cout)。但是现在,我想在线提交我的源代码,我想禁用所有控制台日志记录 (clog) 但保留控制台输出 (cout)

我当然可以评论我所有的//std::clog,但是有没有更好的方法来禁用我的源文件中的所有日志记录,?

最佳答案

您可以重定向阻塞,创建您自己的 ofstream 并使用 rdbuf功能。

std::ofstream nullstream;
std::clog.rdbuf(nullstream.rdbuf());

关于c++ - 如何从源代码中禁用 std::clog 日志记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39161002/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com