void LogHandlerTest() { OriginalLogHandler = GetLogHandler(); dummyAddCleanup( []( void* _ ){ SetLogHandler(OriginalLogHandler); }, NULL); SetLogHandler([]( LogLevel level, const char* line ){ dummyLog("level=%d line='%s'", level, line); CallCount++; switch(CallCount) { case 1: Require(level == LOG_INFO); Require(strcmp(line, "foo") == 0); break; case 2: Require(level == LOG_ERROR); Require(strcmp(line, "bar") == 0); break; case 3: Require(level == LOG_INFO); Require(strcmp(line, "aaa") == 0); break; case 4: Require(level == LOG_INFO); Require(strcmp(line, "bbb") == 0); break; case 5: Require(level == LOG_INFO); Require(strcmp(line, "ccc") == 0); break; case 6: Require(level == LOG_INFO); Require(strcmp(line, "") == 0); break; default: dummyAbortTest(DUMMY_FAIL_TEST, "Invalid log handler call count: %d", CallCount); } }); CallCount = 0; Log("foo"); Error("bar"); Log("aaa\nbbb"); Log("ccc\n"); Require(CallCount == 6); }
FProtoMessagePool() { // Verify that the version of the library that we linked against is // compatible with the version of the headers we compiled against. GOOGLE_PROTOBUF_VERIFY_VERSION; // Turn on protobuffer logging SetLogHandler(ProtobuffErrorHandler); }
bool PostConfigInitLog() { const char* handlerName = GetConfigString("debug.log-handler", "auto"); LogHandler handler = NULL; if(strcmp(handlerName, "simple") == 0) handler = SimpleLogHandler; else if(strcmp(handlerName, "color") == 0) handler = ColorLogHandler; else if(strcmp(handlerName, "auto") == 0) handler = AutodetectLogHandler(); if(handler) { SetLogHandler(handler); return true; } else { Error("Unknown log handler '%s'.", handlerName); return false; } }
extern "C" void SetCenterLogHandler(LogHandlerPtr logHandler) { SetLogHandler(logHandler); }