Skip to content

Instantly share code, notes, and snippets.

@froydnj
Created June 12, 2015 17:11
Show Gist options
  • Save froydnj/7bea36919b53452f09f9 to your computer and use it in GitHub Desktop.
Save froydnj/7bea36919b53452f09f9 to your computer and use it in GitHub Desktop.
lazy log module
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