diff --git a/examples/dotnet/csintegerprogramming.cs b/examples/dotnet/csintegerprogramming.cs index e0faa7b502..2e44b304e9 100644 --- a/examples/dotnet/csintegerprogramming.cs +++ b/examples/dotnet/csintegerprogramming.cs @@ -100,6 +100,8 @@ public class CsIntegerProgramming static void Main() { + Google.OrTools.Init.Init.InitCppLogging("csintegerprogramming.cs", true, false); + Console.WriteLine("---- Integer programming example with GLPK ----"); RunIntegerProgrammingExample("GLPK"); Console.WriteLine("---- Linear programming example with CBC ----"); diff --git a/examples/python/integer_programming.py b/examples/python/integer_programming.py index ca9d908b39..3785a85669 100644 --- a/examples/python/integer_programming.py +++ b/examples/python/integer_programming.py @@ -116,5 +116,7 @@ def main(): if __name__ == '__main__': - init.Init.InitCppLogging('integer_programming.py', False) + init.Init.InitCppLogging('integer_programming.py', + /*logtostderr=*/True, + /*log_prefix=*/False); main() diff --git a/ortools/init/init.h b/ortools/init/init.h index ce3b204c55..a8e0266414 100644 --- a/ortools/init/init.h +++ b/ortools/init/init.h @@ -15,17 +15,20 @@ class Init { // Initialize the C++ logging layer. // If logtostderr is false, all C++ logging will be ignored. // If true, all logging will the displayed on stderr. - static void InitCppLogging(const std::string& program_name, bool logtostderr) { - absl::SetFlag(&FLAGS_logtostderr, logtostderr); - google::InitGoogleLogging(program_name.c_str()); - } + static void InitCppLogging(const std::string& program_name, bool logtostderr, + bool log_prefix) { + absl::SetFlag(&FLAGS_logtostderr, logtostderr); + absl::SetFlag(&FLAGS_log_prefix, log_prefix); + google::InitGoogleLogging(program_name.c_str()); + } // Load the gurobi shared library. // This is necessary if the library is installed in a non canonical // directory, or if for any reason, it is not found. // You need to pass the full path, including the shared library file. - static void LoadGurobiSharedLibrary(const std::string& full_library_path) { - LoadGurobiDynamicLibrary({full_library_path}); + // It returns true if the library was found and correctly loaded. + static bool LoadGurobiSharedLibrary(const std::string& full_library_path) { + return LoadGurobiDynamicLibrary({full_library_path}).ok(); } };