Following changes in most recent FairLogger tag using string_view instead of string#95
Following changes in most recent FairLogger tag using string_view instead of string#95ehellbar wants to merge 1 commit intoAliceO2Group:masterfrom
Conversation
include/InfoLogger/InfoLoggerFMQ.hxx
Outdated
| AliceO2::InfoLogger::InfoLogger::undefinedMessageOption.errorCode, | ||
| metadata.file.c_str(), | ||
| atoi(metadata.line.c_str()) | ||
| std::string(metadata.file.data(), metadata.file.size()).c_str(), |
There was a problem hiding this comment.
Does InfoLoggerMessageOption copy the string?
There was a problem hiding this comment.
No copy, InfoLoggerMessageOption is a POD with a char*. It's meant to be resolved at compile time whenever possible.
There was a problem hiding this comment.
I replaced the char* in InfoLoggerMessageOption with a string_view, plus subsequent changes
There was a problem hiding this comment.
@sy-c thanks for taking care of it.
simply creating the string here 940fefa#diff-36584f894efde34aee0e3aedfd701712f9a7767d6bd748c11dc604bfd937d9acL94 was also my first thought. But @ktf reminded me that std::string(metadata.file) will go out of scope and the const char* of AliceO2::InfoLogger::InfoLogger::InfoLoggerMessageOption opt will point to something undefined. Or am I missing something different?
There was a problem hiding this comment.
You are right, sorry for this. Please use v2.8.1. #97
Valgrind did not complained in my tests, I guess the compiler optimized it as a singleton in the log() call - which is how it is usually written: InfoLoggerMessageOption directly set in the log() call without defining a variable. Here with the IF and two log() we indeed need the intermediate step.
There was a problem hiding this comment.
I guess the compiler optimized it as a singleton in the log() call - which is how it is usually written: InfoLoggerMessageOption directly set in the log() call without defining a variable.
I see, thanks.
FairLogger v2.1.0 introduces a new ("critical") severity to be used in O2. The previous FairLogger used was v1.11.1, so there were further changes in the meantime. One of them is changing std::string members to std::string_view members in https://github.com/FairRootGroup/FairLogger/blob/27527ad87b63213b7c58caf1e34a538e76f273da/logger/Logger.h#L176
This would also require a new InfoLogger tag, to be bumped together with FairLogger in alisw/alidist#5763