35 #include <boost/algorithm/string/predicate.hpp> 36 #include <boost/algorithm/string/trim.hpp> 37 #include <boost/format.hpp> 68 {
Warn,
true,
false,
SCR_STDERR,
false,
"\nWarning ({}, {}(), {:d}):\n"},
69 {
UsrErr,
true,
false,
SCR_NONE,
true,
"\nUser Error ({}, {}(), {:d}):\n"},
70 {
Err,
true,
false,
SCR_NONE,
true,
"\nError ({}, {}(), {:d}):\n"},
71 {
PrgErr,
true,
false,
SCR_NONE,
true,
"\nInternal Error ({}, {}(), {:d}):\n"}
85 int _xprintf(
const char *
const xprintf_file,
const char *
const xprintf_func,
const int xprintf_line,
MessageType type,
const char *
const fmt, ... )
91 static int mpi_msg_id = 0;
106 default: screen=NULL;
112 char format_message[1024];
113 va_start( argptr, fmt );
114 vsprintf(format_message, fmt, argptr);
119 BOOST_THROW_EXCEPTION( ExcXprintfMsg()
120 << EI_XprintfHeader(
fmt::format(mf.
head, xprintf_file, xprintf_func, xprintf_line) )
121 << EI_XprintfMessage( format_message ) );
125 ASSERT(
false).error(
"Non error usage of xprintf is not allowed.");
131 if (mf.
log && sys_info.
log)
135 if ( (screen) && ( sys_info.
my_proc != 0 ) )
143 printf(
"MPI_Barrier() error in xprintf()\n");
144 exit( EXIT_FAILURE );
149 fprintf(screen,
"[msg_id=%d] ", mpi_msg_id );
150 if (mf.
log && sys_info.
log)
151 fprintf(sys_info.
log,
"[msg_id=%d] ", mpi_msg_id );
154 #ifndef FLOW123D_DEBUG_MESSAGES 155 if (type ==
Warn) mf.
head=
"\nWarning: ";
159 if (screen)
fprintf(screen,mf.
head,xprintf_file,xprintf_func,xprintf_line);
160 if (mf.
log && sys_info.
log)
161 fprintf(sys_info.
log,mf.
head,xprintf_file,xprintf_func,xprintf_line);
167 if (mf.
log && sys_info.
log)
169 va_start( argptr, fmt );
170 rc=vfprintf(sys_info.
log,fmt,argptr);
173 fflush(sys_info.
log);
178 va_start( argptr, fmt );
179 rc=vfprintf(screen,fmt,argptr);
bool log
log the message - YES/NO
std::string format(CStringRef format_str, ArgList args)
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
System structure for various global variables.
bool stop
terminate the program
FMT_FUNC int fprintf(std::ostream &os, CStringRef format, ArgList args)
int _xprintf(const char *const xprintf_file, const char *const xprintf_func, const int xprintf_line, MessageType type, const char *const fmt,...)
Multi-purpose printing routine: messages, warnings, errors.
int screen
print to stdout,stderr,NULL
INTERNAL DEFINITIONS FOR XPRINTF.
MessageType
Identifiers for various output messages.
static struct MsgFmt msg_fmt[]
const char * head
message formating string
#define MPI_Barrier(comm)
void printf(BasicWriter< Char > &w, BasicCStringRef< Char > format, ArgList args)
bool mpi
treat as global message (invoke MPI_Barrier() when printing)