Logging: simplify interface
I had a look at the example cmdp log sender and find the interface not entirely satisfying yet:
#define LOGGER logger
Right, this comes from the fact that we can have different loggers and we need to define which one to use for the macros. Just thinking a bit ahead: it might not always be the same logger we use in a given piece of code, so also having LOG(satellite, WARNING)
might be interesting, i.e. providing the logger (or an alias) to the macro.
SinkManager::getInstance().setGlobalConsoleLevel(OFF);
Now we need to understand the entire concept of loggers, sinks, and static instances thereof in order to change the console logging level. How about if we try to move most things into one class and then mostly (only?) interact with static methods e.g. of constellation::Log
? Like constellation::Log::setGlobalConsoleLevel(TRACE)
?
Looking at the interface of the (albeit much simpler) logging mechanism e.g. in APSQ shows the following pattern:
#include "core/utils/log.h"
int main(int argc, const char* argv[]) {
Log::addStream(std::cout);
LogLevel log_level = Log::getLevelFromString(std::string(argv[++i]));
Log::setReportingLevel(log_level);
LOG(INFO) << "...and off we go!";
}