diff options
-rw-r--r-- | mg2d.c | 12 | ||||
-rw-r--r-- | mg2d.h | 35 |
2 files changed, 42 insertions, 5 deletions
@@ -380,7 +380,7 @@ int mg2d_solve(MG2DContext *ctx) priv->root->solver->residual_stride * ctx->domain_size); if (res_cur < ctx->tol) { - mg2di_log(&priv->logger, 0, "converged on iteration %d, residual %g\n", + mg2di_log(&priv->logger, MG2D_LOG_INFO, "converged on iteration %d, residual %g\n", i, res_cur); priv->time_solve += gettime() - time_start; @@ -389,12 +389,13 @@ int mg2d_solve(MG2DContext *ctx) return 0; } - mg2di_log(&priv->logger, 0, "finished toplevel iteration %d, residual %g -> %g (%g)\n", + mg2di_log(&priv->logger, MG2D_LOG_VERBOSE, + "finished toplevel iteration %d, residual %g -> %g (%g)\n", i, res_prev, res_cur, res_prev / res_cur); res_prev = res_cur; } - mg2di_log(&priv->logger, 0, "The solver failed to converge\n"); + mg2di_log(&priv->logger, MG2D_LOG_ERROR, "The solver failed to converge\n"); return -EDOM; } @@ -574,7 +575,7 @@ void mg2d_print_stats(MG2DContext *ctx, const char *prefix) if (!prefix) prefix = ""; - mg2di_log(&priv->logger, 2, "%s%ld solves; %g s total time; %g ms avg per call\n", + mg2di_log(&priv->logger, MG2D_LOG_VERBOSE, "%s%ld solves; %g s total time; %g ms avg per call\n", prefix, priv->count_solve, priv->time_solve / 1e6, priv->time_solve / 1e3 / priv->count_solve); while (level) { @@ -582,7 +583,8 @@ void mg2d_print_stats(MG2DContext *ctx, const char *prefix) level->time_correct + level->time_reinit; int64_t relax_total = level->solver->time_correct + level->solver->time_res_calc + level->solver->time_boundaries; - mg2di_log(&priv->logger, 2, "%s%2.2f%% level %d: %ld cycles %g s total time %g ms avg per call || " + mg2di_log(&priv->logger, MG2D_LOG_VERBOSE, + "%s%2.2f%% level %d: %ld cycles %g s total time %g ms avg per call || " "%2.2f%% relax %2.2f%% prolong %2.2f%% restrict %2.2f%% correct %2.2f%% reinit || " "%2.2f%% residual %2.2f%% correct %2.2f%% boundaries\n", prefix, level_total * 100.0 / priv->time_solve, level->depth, level->count_cycles, @@ -95,6 +95,41 @@ enum MG2DDiffCoeff { MG2D_DIFF_COEFF_NB, }; +enum MG2DLogLevel { + /** + * The log message indicates abnormal program failure. Should never happen + * unless there are bugs or grossly invaid user input. + * Will typically be followed by program termination. + */ + MG2D_LOG_FATAL = 0x0, + /** + * The log message indicates an error state, so that requested operation + * cannot complete successfully. + * Will typically be followed by the API function being called returning an + * error. + */ + MG2D_LOG_ERROR = 0x10, + /** + * The log message indicates a suspicious or suboptimal program state. + */ + MG2D_LOG_WARNING = 0x20, + /** + * The log message provides commonly useful information about normal program + * behaviour. + */ + MG2D_LOG_INFO = 0x30, + /** + * The log message provides detailed extra information about normal program + * behaviour. + */ + MG2D_LOG_VERBOSE = 0x40, + /** + * The log message provides highly detailed extra information about normal + * program behaviour. + */ + MG2D_LOG_DEBUG = 0x50, +}; + typedef struct MG2DInternal MG2DInternal; /** |