From 3485be851f4fff1c9c6fe621f0619d2b4103bc06 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 19 Apr 2025 12:28:52 +0200 Subject: Improved logging, especially for solve --- src/solvers/solutions.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/solvers/solutions.h') diff --git a/src/solvers/solutions.h b/src/solvers/solutions.h index 95c1d1a..c9a1313 100644 --- a/src/solvers/solutions.h +++ b/src/solvers/solutions.h @@ -7,7 +7,8 @@ STATIC bool solution_moves_equal( STATIC bool solution_moves_is_duplicate(size_t n, const solution_moves_t[n+1]); STATIC bool appendchar(solution_list_t [static 1], char); STATIC int64_t appendsolution(const solution_moves_t [static 1], - const solution_settings_t [static 1], solution_list_t [static 1], bool); + const solution_settings_t [static 1], solution_list_t [static 1], bool, + const char *); STATIC bool solutions_done(const solution_list_t [static 1], const solution_settings_t [static 1], int8_t depth); @@ -34,7 +35,7 @@ STATIC bool solution_list_init(solution_list_t sols[static 1], size_t n, char buf[n]) { if (n == 0) { - LOG("Cannot use solution buffer with size 0\n"); + LOG("Error: cannot use solution buffer with size 0\n"); return false; } @@ -98,7 +99,8 @@ appendsolution( const solution_moves_t moves[static 1], const solution_settings_t settings[static 1], solution_list_t list[static 1], - bool log + bool log, + const char *solver_name ) { int64_t r, strl; @@ -184,8 +186,8 @@ appendsolution( if (log) { list->buf[list->used-1] = '\0'; - LOG("Found solution #%" PRIu64 ": %s\n", - list->nsols, last_start); + LOG("[%s solve] Found solution #%" PRIu64 ": %s\n", + solver_name, list->nsols, last_start); list->buf[list->used-1] = '\n'; } } @@ -194,14 +196,14 @@ appendsolution( return r; appendsolution_error_buffer: - LOG("Could not append solution to buffer: size too small\n"); + LOG("[%s solve] Error: buffer too small\n", solver_name); list->buf[0] = '\0'; return NISSY_ERROR_BUFFER_SIZE; appendsolution_error_solution_length: - LOG("Error: solution is too long (%" PRIu8 ").\n" + LOG("[%s solve] Error: solution is too long (%" PRIu8 ").\n" "This is a bug, please report it.\n", - moves->nmoves + moves->npremoves); + solver_name, moves->nmoves + moves->npremoves); list->buf[0] = '\0'; return NISSY_ERROR_UNKNOWN; } -- cgit v1.3