Reputation: 147
Some times, the source string contain multi lines. I found no prefix since second line in log result. I don't want to split the source string to single line, have any idea?
int main()
{
BOOST_LOG_TRIVIAL(info) << "hello\nworld";
return 0;
}
output:
[2017-12-05 09:49:34.957813] [0x000028d4] [info] hello
world
I want the following output:
[2017-12-05 10:01:35.033017] [0x00000af8] [info] hello
[2017-12-05 10:01:35.033017] [0x00000af8] [info] world
Upvotes: 0
Views: 58
Reputation: 10614
Unfortunately, this is not possible to do with Boost.Log. Whatever output you generate in the streaming expression, including newlines, is considered a single log record, which is formatted once, hence it only has one timestamp and other attributes in the output.
You should manually separate the lines into different log records. If the log message text is received from an external source (e.g. network or as a callback from some library), you will have to split the text by newlines yourself.
Upvotes: 1