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-2019 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 scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file message_default.c
17  * @ingroup PUBLICMETHODS
18  * @brief default message handler
19  * @author Stefan Heinz
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #include "scip/pub_message.h"
25 #include "scip/message_default.h"
26 #include "scip/struct_message.h"
27 
28 /*
29  * Local methods
30  */
31 
32 /** prints a message to the given file stream and writes the same messate to the log file */
33 static
35  FILE* file, /**< file stream to print message into */
36  const char* msg /**< message to print (or NULL to flush) */
37  )
38 {
39  if ( msg != NULL )
40  fputs(msg, file);
41  fflush(file);
42 }
43 
44 /*
45  * Callback methods of message handler
46  */
47 
48 /** warning message print method of message handler */
49 static
50 SCIP_DECL_MESSAGEWARNING(messageWarningDefault)
51 { /*lint --e{715}*/
52  if ( msg != NULL && msg[0] != '\0' && msg[0] != '\n' )
53  fputs("WARNING: ", file);
54 
55  logMessage(file, msg);
56 }
57 
58 /** dialog message print method of message handler */
59 static
60 SCIP_DECL_MESSAGEDIALOG(messageDialogDefault)
61 { /*lint --e{715}*/
62  logMessage(file, msg);
63 }
64 
65 /** info message print method of message handler */
66 static
67 SCIP_DECL_MESSAGEINFO(messageInfoDefault)
68 { /*lint --e{715}*/
69  logMessage(file, msg);
70 }
71 
72 /** Create default message handler. To free the message handler use SCIPmessagehdlrRelease(). */
74  SCIP_MESSAGEHDLR** messagehdlr, /**< pointer to store message handler */
75  SCIP_Bool bufferedoutput, /**< should the output be buffered up to the next newline? */
76  const char* filename, /**< name of log file, or NULL (stdout) */
77  SCIP_Bool quiet /**< should screen messages be suppressed? */
78  )
79 {
80  /* create message handler */
81  SCIP_CALL( SCIPmessagehdlrCreate(messagehdlr, bufferedoutput, filename, quiet,
82  messageWarningDefault, messageDialogDefault, messageInfoDefault,
83  NULL, NULL) );
84 
85  return SCIP_OKAY;
86 }
#define NULL
Definition: def.h:253
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:285
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
static SCIP_DECL_MESSAGEWARNING(messageWarningDefault)
#define SCIP_CALL(x)
Definition: def.h:365
#define SCIP_Bool
Definition: def.h:70
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)