Commit 98349610 authored by gsell's avatar gsell

src/h5core/h5_log.c

src/h5core/h5_init.h
src/h5core/h5_log.h:
- cleanup, minor changes
parent aaeca8b6
......@@ -8,6 +8,7 @@
*/
#include "h5core/h5_log.h"
#include "h5core/h5_err.h"
#include "private/h5_init.h"
h5_int32_t h5_log_level = H5_VERBOSE_ERROR;
......@@ -77,3 +78,82 @@ h5_get_loglevel (
) {
return h5_log_level;
}
void
h5priv_vprintf (
FILE* f,
const char* prefix,
const char* __funcname,
const char* fmt,
va_list ap
) {
char fmt2[2048];
snprintf (fmt2, sizeof(fmt2), "[proc %d] %s: %s: %s\n", h5_myproc, prefix,
__funcname, fmt);
vfprintf (f, fmt2, ap);
}
/*!
\ingroup h5_core_errorhandling
Print error message to \c stderr. For use in error handlers only.
*/
void
h5_verror (
const char* const fmt,
va_list ap
) {
if (h5_log_level == 0) return;
char fmt2[2048];
snprintf (fmt2,
sizeof(fmt2), "[proc %d] E: %s: %s\n",
h5_myproc,
h5_call_stack.entry[0].name,
fmt);
vfprintf (stderr, fmt2, ap);
}
h5_err_t
h5_warn (
const char* fmt,
...
) {
if (h5_log_level >= 2) {
va_list ap;
va_start (ap, fmt);
h5priv_vprintf (stderr, "W", h5_get_funcname(), fmt, ap);
va_end (ap);
}
return H5_NOK;
}
void
h5_info (
const char* fmt,
...
) {
if (h5_log_level >= 3) {
va_list ap;
va_start (ap, fmt);
h5priv_vprintf (stdout, "I", h5_get_funcname(), fmt, ap);
va_end (ap);
}
}
void
h5_debug (
const char* const fmt,
...
) {
if (h5_log_level >= 4) {
char prefix[1024];
snprintf (prefix, sizeof(prefix), "%*s %s",
h5_call_stack_get_level(), "",
h5_call_stack_get_name());
va_list ap;
va_start (ap, fmt);
h5priv_vprintf (stdout, "D", prefix, fmt, ap);
va_end (ap);
}
}
......@@ -33,7 +33,7 @@ extern "C" {
extern int h5_initialized;
h5_err_t
h5_initialize (void);
h5priv_initialize (void);
extern h5_dta_types_t h5_dta_types;
extern int h5_myproc;
......
......@@ -16,7 +16,7 @@
#define H5_CORE_API_ENTER(type, fmt, ...) \
if (!h5_initialized) { \
h5_initialize(); \
h5priv_initialize(); \
} \
__FUNC_ENTER(type, H5_DEBUG_CORE_API, fmt, __VA_ARGS__)
#define H5_CORE_API_LEAVE(value) __FUNC_LEAVE(value)
......@@ -50,4 +50,7 @@
#define H5_INLINE_FUNC_LEAVE(expr) __FUNC_LEAVE(expr)
#define H5_INLINE_FUNC_RETURN(expr) __FUNC_RETURN(expr, 0)
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment