|
14 | 14 | #ifndef OR_TOOLS_BASE_INIT_GOOGLE_H_ |
15 | 15 | #define OR_TOOLS_BASE_INIT_GOOGLE_H_ |
16 | 16 |
|
17 | | -#include "absl/flags/declare.h" |
18 | | -#include "absl/flags/flag.h" |
| 17 | +#include "absl/flags/declare.h" // IWYU pragma: keep |
| 18 | +#include "absl/flags/flag.h" // IWYU pragma: keep |
19 | 19 | #include "absl/flags/parse.h" |
20 | 20 | #include "absl/flags/usage.h" |
21 | 21 | #include "absl/log/initialize.h" |
| 22 | +#include "absl/strings/string_view.h" |
| 23 | + |
| 24 | +namespace google { |
| 25 | + |
| 26 | +inline void InitGoogleLogging(absl::string_view usage) { |
| 27 | + absl::InitializeLog(); |
| 28 | + if (!usage.empty()) { |
| 29 | + absl::SetProgramUsageMessage(usage); |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | +inline void ShutdownGoogleLogging() {} // No op. |
| 34 | + |
| 35 | +} // namespace google |
| 36 | + |
22 | 37 | // Initializes misc google-related things in the binary. |
23 | 38 | // |
24 | 39 | // Typically called early on in main() and must be called before other |
|
31 | 46 | // requirement for an element (*argv)[*argc] to exist or to have |
32 | 47 | // any particular value, unlike the similar array that is passed |
33 | 48 | // to the `main` function. |
34 | | -inline void InitGoogle(const char* usage, int* argc, char*** argv, |
| 49 | +inline void InitGoogle(absl::string_view usage, int* argc, char*** argv, |
35 | 50 | bool deprecated) { |
36 | | - absl::InitializeLog(); |
37 | | - absl::SetProgramUsageMessage(usage); |
| 51 | + google::InitGoogleLogging(usage); |
38 | 52 | absl::ParseCommandLine(*argc, *argv); |
39 | 53 | } |
40 | 54 |
|
41 | | -namespace google { |
42 | | - |
43 | | -inline void InitGoogleLogging(const std::string& usage) { |
44 | | - absl::InitializeLog(); |
45 | | - absl::SetProgramUsageMessage(usage); |
| 55 | +inline void InitGoogle(const char* usage, int* argc, char*** argv, |
| 56 | + bool deprecated) { |
| 57 | + InitGoogle(absl::NullSafeStringView(usage), argc, argv, deprecated); |
46 | 58 | } |
47 | 59 |
|
48 | | -inline void ShutdownGoogleLogging() {} // No op. |
49 | | - |
50 | | -} // namespace google |
51 | | - |
52 | 60 | #endif // OR_TOOLS_BASE_INIT_GOOGLE_H_ |
0 commit comments