我有多行代码来触发记录器(INFO模式):
LOG(INFO) << connectionsBOther.at(connectionIdx).line
<< " (" << QString::number(connectionsBOther.at(connectionIdx).direction) << ") | "
<< connectionsBOther.at(connectionIdx).directionTarget
<< " "
<< QString::number(connectionsBOther.at(connectionIdx).departureRelative);输出的示例如下所示:
2017-11-29 14:38:07,643 INFO [default] M85 ( 2) | Hello 1我遇到的问题是,似乎在相应的QString::number()调用之前附加了额外的空间(下面的空格标记为# to mke --它们更可见):
2017-11-29 14:38:07,643 INFO [default] M85#(#2)#|##Hello##1我正在寻找以下输出:
2017-11-29 14:38:07,643 INFO [default] M85#(2)#|#Hello#1我需要为这个输出使用信息。我已经习惯了LOG(DEBUG)在整个地方放置额外的空间,但没想到LOG(INFO)会出现这种情况。
发布于 2017-11-29 14:11:27
根据这个:https://github.com/muflihun/easyloggingpp/issues/179,一个LoggingFlag::AutoSpacing标志是可用的。
来自文档(在https://github.com/muflihun/easyloggingpp#logging-flags):
您可以通过使用静态el::Loggers::addFlag el::Loggers::emove国旗来设置/取消这些标志。您可以通过使用el::Loggers::has国旗检查某些标志是否可用,所有这些函数都采用强类型的enum el::logging国旗。
我认为您应该取消上面提到的标志,以避免自动间隔(即从日志中删除额外的空格)。
更新:
如果不使用<<运算符对您来说不是问题,则始终可以使用级联:
LOG(INFO) << QString(connectionsBOther.at(connectionIdx).line
+ " (" + QString::number(connectionsBOther.at(connectionIdx).direction) + ") | "
+ connectionsBOther.at(connectionIdx).directionTarget
+ " "
+ QString::number(connectionsBOther.at(connectionIdx).departureRelative));https://stackoverflow.com/questions/47554301
复制相似问题