Skip to content

Commit eedb571

Browse files
Use separate functions for warning and error messages (#193)
1 parent f6c48ef commit eedb571

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

include/utils.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ enum ExaGOLogLevel : signed int {
6262
struct ExaGOError : public std::exception {
6363
ExaGOError() : message{"ExaGO Error"} {}
6464
ExaGOError(const char *message) : message{message} {}
65+
ExaGOError(const std::string &message) : message{message} {}
6566
ExaGOError(PetscErrorCode);
6667

6768
/* The name _what_ is not in PascalCase like the rest of ExaGO because
@@ -120,11 +121,21 @@ inline void ExaGOLog(MPI_Comm comm, int level, std::string fmt,
120121
ExaGOCheckError(ierr);
121122
auto logger = spdlog::get(logname);
122123

123-
/*
124-
* Because we handler our own verbosity levels, we just use `info` for all
125-
* log messages.
126-
*/
127-
logger->info(fmt, args...);
124+
switch (level) {
125+
case EXAGO_LOG_ERROR:
126+
logger->error(fmt, args...);
127+
break;
128+
case EXAGO_LOG_WARN:
129+
logger->warn(fmt, args...);
130+
break;
131+
default:
132+
/*
133+
* Because we handle our own verbosity levels, we just use `info` for all
134+
* log messages other than warning and error.
135+
*/
136+
logger->info(fmt, args...);
137+
break;
138+
}
128139
}
129140
#endif
130141
}

0 commit comments

Comments
 (0)