add stderrthreshold to init
This commit is contained in:
@@ -31,6 +31,7 @@ public class InitTest
|
||||
public void CheckFlags()
|
||||
{
|
||||
Init.CppFlags cpp_flags = new Init.CppFlags();
|
||||
cpp_flags.stderrthreshold = 0;
|
||||
cpp_flags.log_prefix = true;
|
||||
cpp_flags.cp_model_dump_prefix = "init";
|
||||
cpp_flags.cp_model_dump_models = true;
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
// Expose the flags structure.
|
||||
%unignore operations_research::CppFlags;
|
||||
%unignore operations_research::CppFlags::logtostderr;
|
||||
%unignore operations_research::CppFlags::stderrthreshold;
|
||||
%unignore operations_research::CppFlags::log_prefix;
|
||||
%unignore operations_research::CppFlags::cp_model_dump_prefix;
|
||||
%unignore operations_research::CppFlags::cp_model_dump_models;
|
||||
|
||||
@@ -31,6 +31,7 @@ ABSL_DECLARE_FLAG(std::string, cp_model_dump_prefix);
|
||||
ABSL_DECLARE_FLAG(bool, cp_model_dump_models);
|
||||
ABSL_DECLARE_FLAG(bool, cp_model_dump_lns);
|
||||
ABSL_DECLARE_FLAG(bool, cp_model_dump_response);
|
||||
ABSL_DECLARE_FLAG(int, stderrthreshold);
|
||||
|
||||
namespace operations_research {
|
||||
|
||||
@@ -39,7 +40,17 @@ namespace operations_research {
|
||||
*/
|
||||
struct CppFlags {
|
||||
/**
|
||||
* Controls is time and source code info are used to prefix logging messages.
|
||||
* @brief Controls the logging level shown on stderr.
|
||||
*
|
||||
* By default, the logger will only display ERROR and FATAL logs (value 2 and
|
||||
* 3) to stderr. To display INFO and WARNING logs (value 0 and 1), change the
|
||||
* threshold to the min value of the message that should be printed.
|
||||
*
|
||||
*/
|
||||
int stderrthreshold = 2;
|
||||
|
||||
/**
|
||||
* @brief Controls if time and source code info are used to prefix logging messages.
|
||||
*/
|
||||
bool log_prefix = false;
|
||||
|
||||
@@ -104,6 +115,7 @@ class CppBridge {
|
||||
* Sets all the C++ flags contained in the CppFlags structure.
|
||||
*/
|
||||
static void SetFlags(const CppFlags& flags) {
|
||||
absl::SetFlag(&FLAGS_stderrthreshold, flags.stderrthreshold);
|
||||
absl::EnableLogPrefix(flags.log_prefix);
|
||||
if (!flags.cp_model_dump_prefix.empty()) {
|
||||
absl::SetFlag(&FLAGS_cp_model_dump_prefix, flags.cp_model_dump_prefix);
|
||||
|
||||
@@ -40,6 +40,7 @@ public final class InitTest {
|
||||
public void testFlags() {
|
||||
final CppFlags cppFlags = new CppFlags();
|
||||
assertNotNull(cppFlags);
|
||||
cppFlags.setStderrthreshold(0);
|
||||
cppFlags.setLog_prefix(true);
|
||||
cppFlags.setCp_model_dump_prefix("init");
|
||||
cppFlags.setCp_model_dump_models(true);
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
// Expose the flags structure.
|
||||
%unignore operations_research::CppFlags;
|
||||
%unignore operations_research::CppFlags::logtostderr;
|
||||
%unignore operations_research::CppFlags::stderrthreshold;
|
||||
%unignore operations_research::CppFlags::log_prefix;
|
||||
%unignore operations_research::CppFlags::cp_model_dump_prefix;
|
||||
%unignore operations_research::CppFlags::cp_model_dump_models;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
// Expose the flags structure.
|
||||
%unignore operations_research::CppFlags;
|
||||
%unignore operations_research::CppFlags::logtostderr;
|
||||
%unignore operations_research::CppFlags::stderrthreshold;
|
||||
%unignore operations_research::CppFlags::log_prefix;
|
||||
%unignore operations_research::CppFlags::cp_model_dump_prefix;
|
||||
%unignore operations_research::CppFlags::cp_model_dump_models;
|
||||
|
||||
@@ -28,6 +28,7 @@ class PyWrapInit(unittest.TestCase):
|
||||
print('test_cpp_flags')
|
||||
cpp_flags = pywrapinit.CppFlags()
|
||||
# print(f'{dir(cpp_flags)}')
|
||||
assert hasattr(cpp_flags, 'stderrthreshold')
|
||||
assert hasattr(cpp_flags, 'log_prefix')
|
||||
assert hasattr(cpp_flags, 'cp_model_dump_prefix')
|
||||
assert hasattr(cpp_flags, 'cp_model_dump_models')
|
||||
|
||||
Reference in New Issue
Block a user