kudu icon indicating copy to clipboard operation
kudu copied to clipboard

logging: We should initialized logging BEFORE InstallLoggingCallback,…

Open wqxiang88 opened this issue 6 years ago • 1 comments

… otherwise the programming will abort(CHECKED(logging_initialized)).

wqxiang88 avatar Apr 23 '19 03:04 wqxiang88

This commit shouldn't be necessary; see this code in client.cc:

// We need to reroute all logging to stderr when the client library is
// loaded. GoogleOnceInit() can do that, but there are multiple entry
// points into the client code, and it'd need to be called in each one.
// So instead, let's use a constructor function.
//
// This is restricted to the exported client builds only. In case of linking
// with non-exported kudu client library, logging must be initialized
// from the main() function of the corresponding binary: usually, that's done
// by calling InitGoogleLoggingSafe(argv[0]).
__attribute__((constructor))
static void InitializeBasicLogging() {
  InitGoogleLoggingSafeBasic(kProgName);

  SetVerboseLevelFromEnvVar();
}

That gets run when libkudu_client.so is loaded at runtime, which is usually one of the first things done by an executable that dynamically links against libkudu_client.so, certainly before main() is run.

What's the complete stack trace on error? Are you building example.cc in some non-standard way?

adembo avatar Apr 23 '19 04:04 adembo