Created
June 12, 2015 17:11
-
-
Save froydnj/7bea36919b53452f09f9 to your computer and use it in GitHub Desktop.
lazy log module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LazyLogModule | |
{ | |
public: | |
MOZ_CONSTEXPR LazyLogModule(const char* aLogName) | |
: mLogName(aLogName), mLog(nullptr) | |
{} | |
operator LogModule*() | |
{ | |
// Carefully, atomically, instantiate a LogModule* if not already | |
// instantiated and return it. | |
} | |
private: | |
const char* mLogName; | |
LogModule* mLog; | |
}; | |
LazyLogModule sNetworkingLog("Networking"); | |
// Later on... | |
MOZ_LOG(sNetworkingLog, ...); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment