solstice-solver

Solver library of the solstice app
git clone git://git.meso-star.com/solstice-solver.git
Log | Files | Refs | README | LICENSE

commit b71f45d0999bccb403ad47582f9bd31bf04f0708
parent 5314245d73e5ba455779e89a6369054204cde16c
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 13 Jul 2016 09:59:18 +0200

Add the internal log_<err|warn> functions

Conditionally print a message on the error or warning stream with
respect to the verbose flag of the device.

Diffstat:
Msrc/ssol_device.c | 41+++++++++++++++++++++++++++++++++++++++++
Msrc/ssol_device_c.h | 24++++++++++++++++++++++++
2 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/src/ssol_device.c b/src/ssol_device.c @@ -24,6 +24,22 @@ /******************************************************************************* * Helper functions ******************************************************************************/ +static INLINE void +log_msg + (struct ssol_device* dev, + const enum log_type stream, + const char* msg, + va_list vargs) +{ + ASSERT(dev && msg); + if(dev->verbose) { + res_T res; (void)res; + res = logger_vprint(dev->logger, stream, msg, vargs); + ASSERT(res == RES_OK); + } +} + + static void device_release(ref_T* ref) { @@ -99,3 +115,28 @@ ssol_device_ref_put(struct ssol_device* dev) return RES_OK; } +/******************************************************************************* + * Local functions + ******************************************************************************/ +void +log_error(struct ssol_device* dev, const char* msg, ...) +{ + va_list vargs_list; + ASSERT(dev && msg); + + va_start(vargs_list, msg); + log_msg(dev, LOG_ERROR, msg, vargs_list); + va_end(vargs_list); +} + +void +log_warning(struct ssol_device* dev, const char* msg, ...) +{ + va_list vargs_list; + ASSERT(dev && msg); + + va_start(vargs_list, msg); + log_msg(dev, LOG_WARNING, msg, vargs_list); + va_end(vargs_list); +} + diff --git a/src/ssol_device_c.h b/src/ssol_device_c.h @@ -30,5 +30,29 @@ struct ssol_device { ref_T ref; }; +/* Conditionally log a message on the LOG_ERROR stream of the device logger, + * with respect to the device verbose flag */ +extern LOCAL_SYM void +log_error + (struct ssol_device* dev, + const char* msg, + ...) +#ifdef COMPILER_GCC + __attribute((format(printf, 2, 3))) +#endif +; + +/* Conditionally log a message on the LOG_WARNING stream of the device logger, + * with respect to the device verbose flag */ +extern LOCAL_SYM void +log_warning + (struct ssol_device* dev, + const char* msg, + ...) +#ifdef COMPILER_GCC + __attribute((format(printf, 2, 3))) +#endif +; + #endif /* SSOL_DEVICE_C_H */