Information
We are currently investigating an issue with the editor of some pages. Please save your work and avoid to create new pages until this banner is gone.
How do I change the name GlobalLogger or StaticMethodLogger within C++ logs?
To answer this question completely, a little background on how the ACS logging system in C++ works is needed. Basically all the non-static context logging macros defined within loggingACEMACROS.h are dependent upon a single function or method being available:
Logging::Logger::LoggerSmartPtr getLogger();
which ACS has implemented in the logging library already. The name of the Logger object returned by this ACS-implemented function is GlobalLogger. The macros themselves then just make calls to getLogger()->log(...)
which of course is completely hidden.
A positive consequence of this is that:
getLogger
having a signature identical to the getLogger()
function described abovegetLogger
method instead of the globally available getLogger()
functiongetLogger
which just changes the name of the SourceObject (i.e., "GlobalLogger") could be something like:protected: Logging::Logger::LoggerSmartPtr getLogger() { return ::getNamedLogger("whatever name I choose"); }
In this case, all we do is use another ACS-provided function to create a Logger with a name of our choice.
As for changing the name of the Logger used by static logging macros:
getNamedLogger
following the signature defined in loggingGetLogger.hgetNamedLogger
implementation, ignore the name parameter being passed in entirely. Instead, use whatever name you want.getNamedLogger
could be:Logging::Logger::LoggerSmartPtr getNamedLogger(const std::string& loggerName) { return ::getNamedLogger("my name and not loggerName"); }