logging: add a default handler during early initialization
Summary: This updates the code to create a default LogHandler that logs to stderr when the main LoggerDB singleton is first created. With this change users will get reasonable log behavior even if they never call `folly::initLogging()` (log messages will go to stderr instead of being ignored). This new initialization code can potentially run very early during program initialization (before `main()` starts and before folly `Singleton` initialization) if some code in the program logs messages before main. However this current initialization code should be safe to run before main. For compilers that support weak symbols (clang and gcc), I have defined `initializeLoggerDB()` as a weak symbol, allowing users to override this behavior at link time on a per-program basis should they choose to. Reviewed By: yfeldblum Differential Revision: D6893207 fbshipit-source-id: 13b72a01aa383c4611204df88ff8dad93abcc7b2
Showing
Please register or sign in to comment