Scippy

SCIP

Solving Constraint Integer Programs

message_default.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (c) 2002-2023 Zuse Institute Berlin (ZIB) */
7 /* */
8 /* Licensed under the Apache License, Version 2.0 (the "License"); */
9 /* you may not use this file except in compliance with the License. */
10 /* You may obtain a copy of the License at */
11 /* */
12 /* http://www.apache.org/licenses/LICENSE-2.0 */
13 /* */
14 /* Unless required by applicable law or agreed to in writing, software */
15 /* distributed under the License is distributed on an "AS IS" BASIS, */
16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17 /* See the License for the specific language governing permissions and */
18 /* limitations under the License. */
19 /* */
20 /* You should have received a copy of the Apache-2.0 license */
21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22 /* */
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 
25 /**@file message_default.c
26  * @ingroup PUBLICMETHODS
27  * @brief default message handler
28  * @author Stefan Heinz
29  */
30 
31 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32 
33 #include "scip/pub_message.h"
34 #include "scip/message_default.h"
35 #include "scip/struct_message.h"
36 
37 /*
38  * Local methods
39  */
40 
41 /** prints a message to the given file stream and writes the same messate to the log file */
42 static
44  FILE* file, /**< file stream to print message into */
45  const char* msg /**< message to print (or NULL to flush) */
46  )
47 {
48  if ( msg != NULL )
49  fputs(msg, file);
50  fflush(file);
51 }
52 
53 /*
54  * Callback methods of message handler
55  */
56 
57 /** warning message print method of message handler */
58 static
59 SCIP_DECL_MESSAGEWARNING(messageWarningDefault)
60 { /*lint --e{715}*/
61  if ( msg != NULL && msg[0] != '\0' && msg[0] != '\n' )
62  fputs("WARNING: ", file);
63 
64  logMessage(file, msg);
65 }
66 
67 /** dialog message print method of message handler */
68 static
69 SCIP_DECL_MESSAGEDIALOG(messageDialogDefault)
70 { /*lint --e{715}*/
71  logMessage(file, msg);
72 }
73 
74 /** info message print method of message handler */
75 static
76 SCIP_DECL_MESSAGEINFO(messageInfoDefault)
77 { /*lint --e{715}*/
78  logMessage(file, msg);
79 }
80 
81 /** Create default message handler. To free the message handler use SCIPmessagehdlrRelease(). */
83  SCIP_MESSAGEHDLR** messagehdlr, /**< pointer to store message handler */
84  SCIP_Bool bufferedoutput, /**< should the output be buffered up to the next newline? */
85  const char* filename, /**< name of log file, or NULL (stdout) */
86  SCIP_Bool quiet /**< should screen messages be suppressed? */
87  )
88 {
89  /* create message handler */
90  SCIP_CALL( SCIPmessagehdlrCreate(messagehdlr, bufferedoutput, filename, quiet,
91  messageWarningDefault, messageDialogDefault, messageInfoDefault,
92  NULL, NULL) );
93 
94  return SCIP_OKAY;
95 }
default message handler
static SCIP_DECL_MESSAGEINFO(messageInfoDefault)
datastructures for problem statistics
SCIP_RETCODE SCIPmessagehdlrCreate(SCIP_MESSAGEHDLR **messagehdlr, SCIP_Bool bufferedoutput, const char *filename, SCIP_Bool quiet, SCIP_DECL_MESSAGEWARNING((*messagewarning)), SCIP_DECL_MESSAGEDIALOG((*messagedialog)), SCIP_DECL_MESSAGEINFO((*messageinfo)), SCIP_DECL_MESSAGEHDLRFREE((*messagehdlrfree)), SCIP_MESSAGEHDLRDATA *messagehdlrdata)
Definition: message.c:295
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
static SCIP_DECL_MESSAGEWARNING(messageWarningDefault)
#define NULL
Definition: lpi_spx1.cpp:164
#define SCIP_CALL(x)
Definition: def.h:394
#define SCIP_Bool
Definition: def.h:93
static void logMessage(FILE *file, const char *msg)
SCIP_RETCODE SCIPcreateMessagehdlrDefault(SCIP_MESSAGEHDLR **messagehdlr, SCIP_Bool bufferedoutput, const char *filename, SCIP_Bool quiet)
public methods for message output
static SCIP_DECL_MESSAGEDIALOG(messageDialogDefault)