1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 2 /* */ 3 /* This file is part of the program and library */ 4 /* SCIP --- Solving Constraint Integer Programs */ 5 /* */ 6 /* Copyright (C) 2002-2021 Konrad-Zuse-Zentrum */ 7 /* fuer Informationstechnik Berlin */ 8 /* */ 9 /* SCIP is distributed under the terms of the ZIB Academic License. */ 10 /* */ 11 /* You should have received a copy of the ZIB Academic License */ 12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */ 13 /* */ 14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 16 /**@file scip_message.h 17 * @ingroup PUBLICCOREAPI 18 * @brief public methods for message handling 19 * @author Tobias Achterberg 20 * @author Timo Berthold 21 * @author Thorsten Koch 22 * @author Alexander Martin 23 * @author Marc Pfetsch 24 * @author Kati Wolter 25 * @author Gregor Hendel 26 * @author Leona Gottwald 27 */ 28 29 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 30 31 #ifndef __SCIP_SCIP_MESSAGE_H__ 32 #define __SCIP_SCIP_MESSAGE_H__ 33 34 35 #include "scip/def.h" 36 #include "scip/type_message.h" 37 #include "scip/type_retcode.h" 38 #include "scip/type_scip.h" 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /**@addtogroup MessageOutputMethods 45 * 46 * @{ 47 */ 48 49 /* if we have a C99 compiler */ 50 #ifdef SCIP_HAVE_VARIADIC_MACROS 51 52 /** prints a debugging message if SCIP_DEBUG flag is set */ 53 #ifdef SCIP_DEBUG 54 #define SCIPdebugMsg(scip, ...) SCIPprintDebugMessage(scip, __FILE__, __LINE__, __VA_ARGS__) 55 #define SCIPdebugMsgPrint(scip, ...) SCIPdebugMessagePrint(scip, __VA_ARGS__) 56 #else 57 #define SCIPdebugMsg(scip, ...) while ( FALSE ) SCIPprintDebugMessage(scip, __FILE__, __LINE__, __VA_ARGS__) 58 #define SCIPdebugMsgPrint(scip, ...) while ( FALSE ) SCIPdebugMessagePrint(scip, __VA_ARGS__) 59 #endif 60 61 #else 62 /* if we do not have a C99 compiler, use a workaround that prints a message, but not the file and linenumber */ 63 64 /** prints a debugging message if SCIP_DEBUG flag is set */ 65 #ifdef SCIP_DEBUG 66 #define SCIPdebugMsg printf("debug: "), SCIPdebugMessagePrint 67 #define SCIPdebugMsgPrint SCIPdebugMessagePrint 68 #else 69 #define SCIPdebugMsg while ( FALSE ) SCIPdebugMessagePrint 70 #define SCIPdebugMsgPrint while ( FALSE ) SCIPdebugMessagePrint 71 #endif 72 73 #endif 74 75 76 /** installs the given message handler, such that all messages are passed to this handler. A messages handler can be 77 * created via SCIPmessagehdlrCreate(). 78 * 79 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 80 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 81 * 82 * @pre this method can be called in one of the following stages of the SCIP solving process: 83 * - \ref SCIP_STAGE_INIT 84 * - \ref SCIP_STAGE_PROBLEM 85 * 86 * @note The currently installed messages handler gets freed if this SCIP instance is its last user (w.r.t. capture/release). 87 */ 88 SCIP_EXPORT 89 SCIP_RETCODE SCIPsetMessagehdlr( 90 SCIP* scip, /**< SCIP data structure */ 91 SCIP_MESSAGEHDLR* messagehdlr /**< message handler to install, or NULL to suppress all output */ 92 ); 93 94 /** returns the currently installed message handler 95 * 96 * @return the currently installed message handler, or NULL if messages are currently suppressed 97 */ 98 SCIP_EXPORT 99 SCIP_MESSAGEHDLR* SCIPgetMessagehdlr( 100 SCIP* scip /**< SCIP data structure */ 101 ); 102 103 /** sets the log file name for the currently installed message handler */ 104 SCIP_EXPORT 105 void SCIPsetMessagehdlrLogfile( 106 SCIP* scip, /**< SCIP data structure */ 107 const char* filename /**< name of log file, or NULL (no log) */ 108 ); 109 110 /** sets the currently installed message handler to be quiet (or not) */ 111 SCIP_EXPORT 112 void SCIPsetMessagehdlrQuiet( 113 SCIP* scip, /**< SCIP data structure */ 114 SCIP_Bool quiet /**< should screen messages be suppressed? */ 115 ); 116 117 /** prints a warning message via the message handler */ 118 #ifdef __GNUC__ 119 __attribute__((format(printf, 2, 3))) 120 #endif 121 SCIP_EXPORT 122 void SCIPwarningMessage( 123 SCIP* scip, /**< SCIP data structure */ 124 const char* formatstr, /**< format string like in printf() function */ 125 ... /**< format arguments line in printf() function */ 126 ); 127 128 /** prints a debug message */ 129 #ifdef __GNUC__ 130 __attribute__((format(printf, 4, 5))) 131 #endif 132 SCIP_EXPORT 133 void SCIPprintDebugMessage( 134 SCIP* scip, /**< SCIP data structure */ 135 const char* sourcefile, /**< name of the source file that called the function */ 136 int sourceline, /**< line in the source file where the function was called */ 137 const char* formatstr, /**< format string like in printf() function */ 138 ... /**< format arguments line in printf() function */ 139 ); 140 141 /** prints a debug message without precode */ 142 #ifdef __GNUC__ 143 __attribute__((format(printf, 2, 3))) 144 #endif 145 SCIP_EXPORT 146 void SCIPdebugMessagePrint( 147 SCIP* scip, /**< SCIP data structure */ 148 const char* formatstr, /**< format string like in printf() function */ 149 ... /**< format arguments line in printf() function */ 150 ); 151 152 /** prints a dialog message that requests user interaction or is a direct response to a user interactive command */ 153 #ifdef __GNUC__ 154 __attribute__((format(printf, 3, 4))) 155 #endif 156 SCIP_EXPORT 157 void SCIPdialogMessage( 158 SCIP* scip, /**< SCIP data structure */ 159 FILE* file, /**< file stream to print into, or NULL for stdout */ 160 const char* formatstr, /**< format string like in printf() function */ 161 ... /**< format arguments line in printf() function */ 162 ); 163 164 /** prints a message */ 165 #ifdef __GNUC__ 166 __attribute__((format(printf, 3, 4))) 167 #endif 168 SCIP_EXPORT 169 void SCIPinfoMessage( 170 SCIP* scip, /**< SCIP data structure */ 171 FILE* file, /**< file stream to print into, or NULL for stdout */ 172 const char* formatstr, /**< format string like in printf() function */ 173 ... /**< format arguments line in printf() function */ 174 ); 175 176 /** prints a message depending on the verbosity level */ 177 #ifdef __GNUC__ 178 __attribute__((format(printf, 4, 5))) 179 #endif 180 SCIP_EXPORT 181 void SCIPverbMessage( 182 SCIP* scip, /**< SCIP data structure */ 183 SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */ 184 FILE* file, /**< file stream to print into, or NULL for stdout */ 185 const char* formatstr, /**< format string like in printf() function */ 186 ... /**< format arguments line in printf() function */ 187 ); 188 189 /** returns the current message verbosity level 190 * 191 * @return message verbosity level of SCIP 192 * 193 * @see \ref SCIP_VerbLevel "SCIP_VERBLEVEL" for a list of all verbosity levels 194 */ 195 SCIP_EXPORT 196 SCIP_VERBLEVEL SCIPgetVerbLevel( 197 SCIP* scip /**< SCIP data structure */ 198 ); 199 200 201 /**@} */ 202 203 #ifdef __cplusplus 204 } 205 #endif 206 207 #endif 208