Commit 2da69d10 authored by gsell's avatar gsell

error in logging/debug output fixed, see issue #13

parent 15317a9b
......@@ -9,7 +9,9 @@
#include "h5core/h5_log.h"
#include "h5core/h5_err.h"
#include "private/h5_init.h"
extern int h5_myproc;
#include <stdlib.h>
......
......@@ -9,9 +9,13 @@
#include "h5core/h5_log.h"
#include "h5core/h5_err.h"
#include "private/h5_init.h"
h5_int32_t h5_log_level = H5_VERBOSE_ERROR;
extern int h5_myproc;
h5_int64_t h5_log_level = H5_VERBOSE_ERROR;
h5_int64_t h5_debug_mask = 0;
struct call_stack h5_call_stack;
char *h5_rfmts[] = {
......@@ -20,7 +24,10 @@ char *h5_rfmts[] = {
[e_char_p] = "%s",
[e_void_p] = "%p",
[e_h5_err_t] = "%lld",
[e_h5_int32_t] = "%ld",
[e_h5_uint32_t] = "%lu",
[e_h5_int64_t] = "%lld",
[e_h5_uint64_t] = "%llu",
[e_h5_id_t] = "%lld",
[e_h5_ssize_t] = "%lld",
[e_h5_errorhandler_t] = "%p",
......@@ -56,12 +63,18 @@ char *h5_rfmts[] = {
*/
h5_err_t
h5_set_loglevel (
const h5_id_t level /*!< debug level */
const h5_int64_t level /*!< log level */
) {
if (level < 0)
h5_log_level = ((1 << 20) - 1) & ~0x7;
else
h5_log_level = level;
h5_log_level = level & 0x7;
return H5_SUCCESS;
}
h5_err_t
h5_set_debug_mask (
const h5_int64_t mask /*!< debug level */
) {
h5_log_level = H5_VERBOSE_DEBUG;
h5_debug_mask = mask;
return H5_SUCCESS;
}
......@@ -72,7 +85,7 @@ h5_set_loglevel (
\return current debug level
*/
h5_err_t
h5_int64_t
h5_get_loglevel (
void
) {
......
......@@ -2002,7 +2002,7 @@ distribute_octree_parmetis (
TRY (vtxdist = h5_calloc (m->f->nprocs+1, sizeof (*vtxdist)));
vtxdist[0] = 0;
#if !defined(NDEBUG)
if (h5_log_level & (1<<5) ) {
if (h5_debug_mask & (1<<5) ) {
h5_debug ("vtxdist[%d]: %d", 0, 0);
}
#endif
......@@ -2014,7 +2014,7 @@ distribute_octree_parmetis (
vtxdist[i] = vtxdist[i-1] + n;
}
#if !defined(NDEBUG)
if (h5_log_level & (1<<5) ) {
if (h5_debug_mask & (1<<5) ) {
h5_debug ("vtxdist[%d]: %d", i, vtxdist[i]);
}
#endif
......@@ -2060,7 +2060,7 @@ distribute_octree_parmetis (
}
xadj[i+1] = xadj[i] + num_neigh;
#if !defined(NDEBUG)
if (h5_log_level & (1<<5) ) {
if (h5_debug_mask & (1<<5) ) {
h5_debug ("xadj[%d]: %d", i+1, xadj[i+1]);
}
#endif
......@@ -2070,7 +2070,7 @@ distribute_octree_parmetis (
if (new_numbering[j] == neighbors[k]) {
adjncy[counter] = j;
#if !defined(NDEBUG)
if (h5_log_level & (1<<5) ) {
if (h5_debug_mask & (1<<5) ) {
h5_debug ("adjncy[%d]: %d", counter, adjncy[counter]);
}
#endif
......@@ -2139,7 +2139,7 @@ distribute_octree_parmetis (
TRY (h5_free (ubvec));
#if !defined(NDEBUG)
if (h5_log_level & (1<<5) ) {
if (h5_debug_mask & (1<<5) ) {
for (i = 0; i < num_interior_oct; i++) {
h5_debug ("part[%d]: %llu", i, (unsigned long long)part[i]);
}
......@@ -2498,7 +2498,7 @@ read_chunked_elements (
#if NDEBUG == 0
if (h5_log_level & (1<<6) ) {
if (h5_debug_mask & (1<<6) ) {
sleep (m->f->myproc*2);
for (int i = 0; i < num_interior_elems;i++) {
h5_debug ("\n"
......
......@@ -23,8 +23,8 @@
#define __FUNC_ENTER(type, mask, fmt, ...) \
type ret_value = (type)H5_ERR; \
int __log__ = h5_log_level & mask; \
if (__log__ ) { \
int __log__ = h5_debug_mask & mask; \
if (__log__) { \
h5_call_stack_push (__func__,e_##type); \
h5_debug ("(" fmt ")", __VA_ARGS__); \
}
......@@ -33,7 +33,7 @@
#define H5_CORE_API_ENTER(type, fmt, ...) \
if (!h5_initialized) { \
h5priv_initialize(); \
h5_initialize(); \
} \
__FUNC_ENTER(type, H5_DEBUG_CORE_API, fmt, __VA_ARGS__)
......
......@@ -219,7 +219,7 @@ update_internal_structs (
// create index sets
#if (!defined(NDEBUG) && (h5_log_level & (1<<5)))
#if (!defined(NDEBUG) && (h5_debug_mask & (1<<5)))
if (!m->is_chunked) {
h5t_adjacencies_t* adj = &m->adjacencies;
h5_loc_idx_t idx = 0;
......
......@@ -202,7 +202,7 @@ compute_neighbor_of_face (
}
if (elem_idx < -1) { // this should only happen if we are on the boarder
// of a loaded chunk and the parent is on a different chunk
if (h5_log_level >= 6) {
if (h5_debug_mask >= 6) {
h5_debug ("Elem %d is on different proc than its parent %d \n"
"therefore neighborhood idx is not correct resolved", old_elem_idx, elem_idx);
}
......
......@@ -50,7 +50,7 @@ extern "C" {
*/
static inline h5_err_t
H5SetVerbosityLevel2 (
const h5_id_t level ///< [in] verbosity level.
const h5_int32_t level ///< [in] verbosity level.
) {
return h5_set_loglevel (level & 0x03);
}
......@@ -72,7 +72,7 @@ H5SetVerbosityLevel2 (
*/
static inline h5_err_t
H5SetVerbosityLevel1 (
const h5_id_t level ///< [in] verbosity level.
const h5_int64_t level ///< [in] verbosity level.
) {
return h5_set_loglevel (level);
}
......@@ -84,7 +84,7 @@ H5SetVerbosityLevel1 (
\see H5SetVerbosityLevel()
*/
static inline h5_id_t
static inline h5_int64_t
H5GetVerbosityLevel (
void
) {
......@@ -123,9 +123,9 @@ H5GetVerbosityLevel (
*/
static inline h5_err_t
H5SetDebugMask (
const h5_id_t mask ///< [in] debug mask
const h5_int64_t mask ///< [in] debug mask
) {
return h5_set_loglevel (mask & ~0x03);
return h5_set_debug_mask (mask);
}
/**
......@@ -140,7 +140,7 @@ H5SetDebugMask (
| :------ | :----- |
| \c 1.99.15 | Function introduced in this release. |
*/
static inline h5_id_t
static inline h5_int32_t
H5GetDebugMask (
void
) {
......
......@@ -22,6 +22,7 @@ extern const char* H5_VER_STRING;
#define H5_VERBOSE_ERROR (1)
#define H5_VERBOSE_WARN (2)
#define H5_VERBOSE_INFO (3)
#define H5_VERBOSE_DEBUG (4)
#define H5_VERBOSE_DEFAULT H5_VERBOSE_ERROR
......@@ -45,7 +46,10 @@ enum h5_rtypes {
e_char_p,
e_void_p,
e_h5_err_t,
e_h5_int32_t,
e_h5_uint32_t,
e_h5_int64_t,
e_h5_uint64_t,
e_h5_id_t,
e_h5_ssize_t,
e_h5_errorhandler_t,
......@@ -75,9 +79,15 @@ struct call_stack {
struct call_stack_entry entry[1024];
};
extern h5_int32_t h5_log_level;
extern h5_int64_t h5_log_level;
extern h5_int64_t h5_debug_mask;
extern struct call_stack h5_call_stack;
// :FIXME: Should go to another header file
h5_err_t
h5_initialize (void);
#ifdef __cplusplus
extern "C" {
#endif
......@@ -182,9 +192,13 @@ __attribute__ ((format (printf, 1, 2)))
h5_err_t
h5_set_loglevel (
const h5_id_t);
const h5_int64_t);
h5_err_t
h5_set_debug_mask (
const h5_int64_t);
h5_int64_t
h5_get_loglevel (
void);
......@@ -198,15 +212,19 @@ h5_get_loglevel (
#define H5_API_ENTER(type, fmt, ...) \
type ret_value = (type)H5_ERR;
h5_initialize();
h5_call_stack_reset (); \
h5_call_stack_push (__func__,e_##type); \
#else // NDEBUG not defined
#define H5_API_ENTER(type, fmt, ...) \
h5_call_stack_reset (); \
type ret_value = (type)H5_ERR; \
int __log__ = h5_log_level & H5_DEBUG_API; \
h5_initialize(); \
h5_call_stack_reset (); \
h5_call_stack_push (__func__,e_##type); \
int __log__ = h5_debug_mask & H5_DEBUG_API; \
if (__log__) { \
h5_call_stack_push (__func__,e_##type); \
h5_debug ("(" fmt ")", __VA_ARGS__); \
}
......@@ -220,7 +238,7 @@ h5_get_loglevel (
}
#define H5_RETURN_ERROR(errno, fmt, ...) { \
ret_value = h5_error (errno, "(" fmt ")", __VA_ARGS__); \
ret_value = h5_error (errno, fmt, __VA_ARGS__); \
goto done; \
}
......
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