Manticore  Version 1.0
Physics of Molecular Clouds
Classes | Namespaces | Macros | Functions
Log.h File Reference

Declares diagnostic message macros. More...

#include <cerrno>
#include <cstdio>
#include <cstring>
#include <string>
Include dependency graph for Log.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mutils::Log
 Logging facility. More...
 

Namespaces

 mutils
 MathUtils package.
 

Macros

#define MU_DEBUG(src, msg, ...)   MU_MESSAGE(mutils::Log::DEBUG, src, msg, ## __VA_ARGS__)
 Log a message at level Log::DEBUG. More...
 
#define MU_DEBUG_IF(cond, src, msg, ...)   MU_MESSAGE_IF(mutils::Log::DEBUG, cond, src, msg, ## __VA_ARGS__)
 Conditionally log a message at level Log::DEBUG. More...
 
#define MU_DEBUG_RTN(rtn, cond, src, msg, ...)   MU_MESSAGE_RTN(mutils::Log::DEBUG, rtn, cond, src, msg, ## __VA_ARGS__)
 Conditionally log a message at level Log::DEBUG (with return). More...
 
#define MU_ERRNO_IF(cond, src, msg, ...)
 Conditionally log a message at level Log::ERROR (with errno). More...
 
#define MU_ERRNO_RTN(rtn, cond, src, msg, ...)
 Conditionally log a message at level Log::ERRROR (with errno and return). More...
 
#define MU_ERROR(src, msg, ...)   MU_MESSAGE(mutils::Log::ERROR, src, msg, ## __VA_ARGS__)
 Log a message at level Log::ERROR. More...
 
#define MU_ERROR_IF(cond, src, msg, ...)   MU_MESSAGE_IF(mutils::Log::ERROR, cond, src, msg, ## __VA_ARGS__)
 Conditionally log a message at level Log::ERROR. More...
 
#define MU_ERROR_RTN(rtn, cond, src, msg, ...)   MU_MESSAGE_RTN(mutils::Log::ERROR, rtn, cond, src, msg, ## __VA_ARGS__)
 Conditionally log a message at level Log::ERROR (with return). More...
 
#define MU_INFO(src, msg, ...)   MU_MESSAGE(mutils::Log::INFO, src, msg, ## __VA_ARGS__)
 Log a message at level Log::INFO. More...
 
#define MU_INFO_IF(cond, src, msg, ...)   MU_MESSAGE_IF(mutils::Log::INFO, cond, src, msg, ## __VA_ARGS__)
 Conditionally log a message at level Log::INFO. More...
 
#define MU_INFO_RTN(rtn, cond, src, msg, ...)   MU_MESSAGE_RTN(mutils::Log::INFO, rtn, cond, src, msg, ## __VA_ARGS__)
 Conditionally log a message at level Log::INFO (with return). More...
 
#define MU_MESSAGE(lev, src, msg, ...)
 Uniform messaging macro with variable debug level. More...
 
#define MU_MESSAGE_IF(lev, cond, src, msg, ...)
 Conditionally log a message at specific level. More...
 
#define MU_MESSAGE_RTN(lev, rtn, cond, src, msg, ...)
 Conditionally log a message at a specific level (with return). More...
 
#define MU_WARN(src, msg, ...)   MU_MESSAGE(mutils::Log::WARN, src, msg, ## __VA_ARGS__)
 Log a message at level Log::WARN. More...
 
#define MU_WARN_IF(cond, src, msg, ...)   MU_MESSAGE_IF(mutils::Log::WARN, cond, src, msg, ## __VA_ARGS__)
 Conditionally log a message at level Log::WARN. More...
 
#define MU_WARN_RTN(rtn, cond, src, msg, ...)   MU_MESSAGE_RTN(mutils::Log::WARN, rtn, cond, src, msg, ## __VA_ARGS__)
 Conditionally log a message at level Log::WARN (with return). More...
 

Functions

const char * mutils::Cform (const std::string &s)
 Converts input to well-defined type for stdio. More...
 
template<typename T >
T * mutils::Cform (T *p)
 Converts input to well-defined type for stdio. More...
 
double mutils::Cform (double i)
 Converts input to well-defined type for stdio. More...
 
unsigned long mutils::Cform (unsigned long long i)
 Converts input to well-defined type for stdio. More...
 
unsigned long mutils::Cform (unsigned long i)
 Converts input to well-defined type for stdio. More...
 
unsigned long mutils::Cform (unsigned i)
 Converts input to well-defined type for stdio. More...
 
long mutils::Cform (long long i)
 Converts input to well-defined type for stdio. More...
 
long mutils::Cform (long i)
 Converts input to well-defined type for stdio. More...
 
long mutils::Cform (int i)
 Converts input to well-defined type for stdio. More...
 
int mutils::Cform (unsigned char i)
 Converts input to well-defined type for stdio. More...
 
int mutils::Cform (char i)
 Converts input to well-defined type for stdio. More...
 
int mutils::cxxfclose (FILE *fp)
 Standardized fclose(). More...
 
FILE * mutils::cxxfopen (const std::string &file, const char *mode)
 Standardized fopen(). More...
 
template<typename... Args>
int mutils::cxxfprintf (FILE *f, Args &&... args)
 C fprintf() with type conversion (not safety). More...
 
template<typename... Args>
int mutils::cxxprintf (Args &&... args)
 C printf() with type conversion (not safety). More...
 
template<typename... Args>
int mutils::cxxsnprintf (char *buf, size_t len, Args &&... args)
 C snprintf() with type conversion (not safety). More...
 

Detailed Description

Declares diagnostic message macros.

Author:  Kevin P. Rauch  <rauch.nosp@m.@ast.nosp@m.ro.um.nosp@m.d.ed.nosp@m.u>

Definition in file Log.h.

Macro Definition Documentation

◆ MU_DEBUG

#define MU_DEBUG (   src,
  msg,
  ... 
)    MU_MESSAGE(mutils::Log::DEBUG, src, msg, ## __VA_ARGS__)

Log a message at level Log::DEBUG.

Parameters
[in]srcSource name (program or method).
[in]msgDebug message (must be a literal string constant).
[in]...Arguments to satisfy msg mutils::cxxprintf directives.
Warning
This must be defined as a macro to get proper line information.

Definition at line 68 of file Log.h.

Referenced by manticore::Detector::calcWidth(), manticore::Detector::init(), and manticore::solveStage1().

◆ MU_DEBUG_IF

#define MU_DEBUG_IF (   cond,
  src,
  msg,
  ... 
)    MU_MESSAGE_IF(mutils::Log::DEBUG, cond, src, msg, ## __VA_ARGS__)

Conditionally log a message at level Log::DEBUG.

Parameters
[in]condFailure test condition.
[in]srcSource name (program or method).
[in]msgError message (must be a literal string constant).
[in]...Arguments to satisfy msg mutils::cxxprintf directives.
Warning
This must be defined as a macro to get proper line information.

Definition at line 78 of file Log.h.

◆ MU_DEBUG_RTN

#define MU_DEBUG_RTN (   rtn,
  cond,
  src,
  msg,
  ... 
)    MU_MESSAGE_RTN(mutils::Log::DEBUG, rtn, cond, src, msg, ## __VA_ARGS__)

Conditionally log a message at level Log::DEBUG (with return).

Parameters
[in]rtnFailure return value.
[in]condFailure test condition.
[in]srcSource name (program or method).
[in]msgError message (must be a literal string constant).
[in]...Arguments to satisfy msg mutils::cxxprintf directives.
Postcondition
If cond is true the caller will return with a value of rtn.
Warning
This must be defined as a macro to get proper line information.

Definition at line 90 of file Log.h.

◆ MU_ERRNO_IF

#define MU_ERRNO_IF (   cond,
  src,
  msg,
  ... 
)
Value:
MU_MESSAGE_IF(mutils::Log::ERROR, cond, src, msg ": %s", \
## __VA_ARGS__, strerror(errno))
#define MU_MESSAGE_IF(lev, cond, src, msg,...)
Conditionally log a message at specific level.
Definition: Log.h:40
static constexpr int ERROR
Error condition.
Definition: Log.h:347

Conditionally log a message at level Log::ERROR (with errno).

Parameters
[in]condFailure test condition.
[in]srcSource name (program or method).
[in]msgError message (must be a literal string constant).
[in]...Arguments to satisfy msg mutils::cxxprintf directives.
Warning
This must be defined as a macro to get proper line information.
This macro is not thread-safe.

Definition at line 198 of file Log.h.

◆ MU_ERRNO_RTN

#define MU_ERRNO_RTN (   rtn,
  cond,
  src,
  msg,
  ... 
)
Value:
MU_MESSAGE_RTN(mutils::Log::ERROR, rtn, cond, src, msg ": %s", \
## __VA_ARGS__, strerror(errno))
#define MU_MESSAGE_RTN(lev, rtn, cond, src, msg,...)
Conditionally log a message at a specific level (with return).
Definition: Log.h:54
static constexpr int ERROR
Error condition.
Definition: Log.h:347

Conditionally log a message at level Log::ERRROR (with errno and return).

Parameters
[in]rtnFailure return value.
[in]condFailure test condition.
[in]srcSource name (program or method).
[in]msgError message (must be a literal string constant).
[in]...Arguments to satisfy msg mutils::cxxprintf directives.
Postcondition
If cond is true the caller will return with a value of rtn.
Warning
This must be defined as a macro to get proper line information.
This macro is not thread-safe.

Definition at line 213 of file Log.h.

◆ MU_ERROR

#define MU_ERROR (   src,
  msg,
  ... 
)    MU_MESSAGE(mutils::Log::ERROR, src, msg, ## __VA_ARGS__)

Log a message at level Log::ERROR.

Parameters
[in]srcSource name (program or method).
[in]msgDebug message (must be a literal string constant).
[in]...Arguments to satisfy msg mutils::cxxprintf directives.
Warning
This must be defined as a macro to get proper line information.

Definition at line 164 of file Log.h.

Referenced by manticore::Dust::setModel().

◆ MU_ERROR_IF

#define MU_ERROR_IF (   cond,
  src,
  msg,
  ... 
)    MU_MESSAGE_IF(mutils::Log::ERROR, cond, src, msg, ## __VA_ARGS__)

Conditionally log a message at level Log::ERROR.

Parameters
[in]condFailure test condition.
[in]srcSource name (program or method).
[in]msgError message (must be a literal string constant).
[in]...Arguments to satisfy msg mutils::cxxprintf directives.
Warning
This must be defined as a macro to get proper line information.

Definition at line 174 of file Log.h.

Referenced by manticore::process().

◆ MU_ERROR_RTN

#define MU_ERROR_RTN (   rtn,
  cond,
  src,
  msg,
  ... 
)    MU_MESSAGE_RTN(mutils::Log::ERROR, rtn, cond, src, msg, ## __VA_ARGS__)

Conditionally log a message at level Log::ERROR (with return).

Parameters
[in]rtnFailure return value.
[in]condFailure test condition.
[in]srcSource name (program or method).
[in]msgError message (must be a literal string constant).
[in]...Arguments to satisfy msg mutils::cxxprintf directives.
Postcondition
If cond is true the caller will return with a value of rtn.
Warning
This must be defined as a macro to get proper line information.

Definition at line 186 of file Log.h.

◆ MU_INFO

#define MU_INFO (   src,
  msg,
  ... 
)    MU_MESSAGE(mutils::Log::INFO, src, msg, ## __VA_ARGS__)

Log a message at level Log::INFO.

Parameters
[in]srcSource name (program or method).
[in]msgDebug message (must be a literal string constant).
[in]...Arguments to satisfy msg mutils::cxxprintf directives.
Warning
This must be defined as a macro to get proper line information.

Definition at line 100 of file Log.h.

Referenced by manticore::getError(), manticore::process(), and manticore::solve().

◆ MU_INFO_IF

#define MU_INFO_IF (   cond,
  src,
  msg,
  ... 
)    MU_MESSAGE_IF(mutils::Log::INFO, cond, src, msg, ## __VA_ARGS__)

Conditionally log a message at level Log::INFO.

Parameters
[in]condFailure test condition.
[in]srcSource name (program or method).
[in]msgError message (must be a literal string constant).
[in]...Arguments to satisfy msg mutils::cxxprintf directives.
Warning
This must be defined as a macro to get proper line information.

Definition at line 110 of file Log.h.

Referenced by manticore::solveStage1().

◆ MU_INFO_RTN

#define MU_INFO_RTN (   rtn,
  cond,
  src,
  msg,
  ... 
)    MU_MESSAGE_RTN(mutils::Log::INFO, rtn, cond, src, msg, ## __VA_ARGS__)

Conditionally log a message at level Log::INFO (with return).

Parameters
[in]rtnFailure return value.
[in]condFailure test condition.
[in]srcSource name (program or method).
[in]msgError message (must be a literal string constant).
[in]...Arguments to satisfy msg mutils::cxxprintf directives.
Postcondition
If cond is true the caller will return with a value of rtn.
Warning
This must be defined as a macro to get proper line information.

Definition at line 122 of file Log.h.

◆ MU_MESSAGE

#define MU_MESSAGE (   lev,
  src,
  msg,
  ... 
)
Value:
do { \
if ((lev) <= mutils::Log::level) { \
mutils::cxxfprintf(mutils::Log::stream, "%s: %s:%0*d: " msg "\n", \
mutils::Log::name(lev), (db ? (src) : ""), \
(db ? 1 : 4), __LINE__, ## __VA_ARGS__); \
} \
} while (0)
static FILE * stream
Message log file stream.
Definition: Log.h:433
static const char * name(int lev=mutils::Log::level)
Standard logging level name string.
Definition: Log.h:355
static int level
Message logging level for output to stream.
Definition: Log.h:430
static constexpr int DEBUG
Verbose information.
Definition: Log.h:350
int cxxfprintf(FILE *f, Args &&... args)
C fprintf() with type conversion (not safety).
Definition: Log.h:284

Uniform messaging macro with variable debug level.

Parameters
[in]levMessage Log::Level.
[in]srcSource name (program or method).
[in]msgDebug message (must be a literal string constant).
[in]...Arguments to satisfy msg mutils::cxxprintf directives.
Warning
This must be defined as a macro to get proper line information.

Definition at line 23 of file Log.h.

◆ MU_MESSAGE_IF

#define MU_MESSAGE_IF (   lev,
  cond,
  src,
  msg,
  ... 
)
Value:
do { \
if (cond) { MU_MESSAGE(lev, src, msg, ## __VA_ARGS__); } \
} while (0)
#define MU_MESSAGE(lev, src, msg,...)
Uniform messaging macro with variable debug level.
Definition: Log.h:23

Conditionally log a message at specific level.

Parameters
[in]levMessage log level.
[in]condFailure test condition.
[in]srcSource name (program or method).
[in]msgError message (must be a literal string constant).
[in]...Arguments to satisfy msg mutils::cxxprintf directives.
Warning
This must be defined as a macro to get proper line information.

Definition at line 40 of file Log.h.

◆ MU_MESSAGE_RTN

#define MU_MESSAGE_RTN (   lev,
  rtn,
  cond,
  src,
  msg,
  ... 
)
Value:
do { \
if (cond) { \
MU_MESSAGE(lev, src, msg, ## __VA_ARGS__); \
return (rtn); \
} \
} while (0)

Conditionally log a message at a specific level (with return).

Parameters
[in]levMessage log level.
[in]rtnFailure return value.
[in]condFailure test condition.
[in]srcSource name (program or method).
[in]msgError message (must be a literal string constant).
[in]...Arguments to satisfy msg mutils::cxxprintf directives.
Postcondition
If cond is true the caller will return with a value of rtn.
Warning
This must be defined as a macro to get proper line information.

Definition at line 54 of file Log.h.

◆ MU_WARN

#define MU_WARN (   src,
  msg,
  ... 
)    MU_MESSAGE(mutils::Log::WARN, src, msg, ## __VA_ARGS__)

Log a message at level Log::WARN.

Parameters
[in]srcSource name (program or method).
[in]msgDebug message (must be a literal string constant).
[in]...Arguments to satisfy msg mutils::cxxprintf directives.
Warning
This must be defined as a macro to get proper line information.

Definition at line 132 of file Log.h.

◆ MU_WARN_IF

#define MU_WARN_IF (   cond,
  src,
  msg,
  ... 
)    MU_MESSAGE_IF(mutils::Log::WARN, cond, src, msg, ## __VA_ARGS__)

Conditionally log a message at level Log::WARN.

Parameters
[in]condFailure test condition.
[in]srcSource name (program or method).
[in]msgError message (must be a literal string constant).
[in]...Arguments to satisfy msg mutils::cxxprintf directives.
Warning
This must be defined as a macro to get proper line information.

Definition at line 142 of file Log.h.

Referenced by manticore::solveStage1().

◆ MU_WARN_RTN

#define MU_WARN_RTN (   rtn,
  cond,
  src,
  msg,
  ... 
)    MU_MESSAGE_RTN(mutils::Log::WARN, rtn, cond, src, msg, ## __VA_ARGS__)

Conditionally log a message at level Log::WARN (with return).

Parameters
[in]rtnFailure return value.
[in]condFailure test condition.
[in]srcSource name (program or method).
[in]msgError message (must be a literal string constant).
[in]...Arguments to satisfy msg mutils::cxxprintf directives.
Postcondition
If cond is true the caller will return with a value of rtn.
Warning
This must be defined as a macro to get proper line information.

Definition at line 154 of file Log.h.