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/coord/gendata.h | 9 +++++---- src/solvers/coord/solve.h | 30 ++++++++++++++++-------------- src/solvers/coord/utils.h | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) (limited to 'src/solvers/coord') diff --git a/src/solvers/coord/gendata.h b/src/solvers/coord/gendata.h index 6abb5eb..ae7b39e 100644 --- a/src/solvers/coord/gendata.h +++ b/src/solvers/coord/gendata.h @@ -22,7 +22,7 @@ gendata_coord_dispatch(const char *coordstr, void *buf) parse_coord_and_axis(strlen(coordstr), coordstr, &coord, NULL); if (coord == NULL) { - LOG("Could not parse coordinate '%s'\n", coordstr); + LOG("Error: could not parse coordinate '%s'\n", coordstr); return NISSY_ERROR_INVALID_SOLVER; } @@ -82,7 +82,7 @@ gendata_coord_return_size: return ninfo * INFOSIZE + coord_dsize + tablesize; gendata_coord_error: - LOG("An unexpected error occurred when generating the data.\n"); + LOG("Unexpected error generating coordinate data\n"); return 0; } @@ -136,8 +136,9 @@ genptable_coord( } tot += t; info.distribution[d] = t; - LOG("Depth %" PRIu64 ": found %" PRIu64 " (%" PRIu64 " of %" - PRIu64 ")\n", d, t, tot, coord->max); + LOG("[%s gendata] Depth %" PRIu64 ": found %" PRIu64 " (%" + PRIu64 " of %" PRIu64 ")\n", + coord->name, d, t, tot, coord->max); } info.maxvalue = d-1; diff --git a/src/solvers/coord/solve.h b/src/solvers/coord/solve.h index b289e3f..072aa27 100644 --- a/src/solvers/coord/solve.h +++ b/src/solvers/coord/solve.h @@ -121,7 +121,8 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[static 1]) if (!coord_solution_admissible(arg)) return 0; return appendsolution(arg->solution_moves, - arg->solution_settings, arg->solution_list, true); + arg->solution_settings, arg->solution_list, true, + arg->coord->name); } if (solve_coord_dfs_stop(arg)) @@ -220,12 +221,13 @@ solve_coord_dispatch( strlen(coord_and_axis), coord_and_axis, &coord, &axis); if (coord == NULL) { - LOG("Could not parse coordinate from '%s'\n", coord_and_axis); + LOG("Error: could not parse coordinate from '%s'\n", + coord_and_axis); return NISSY_ERROR_INVALID_SOLVER; } if (axis == UINT8_ERROR) { - LOG("Could not parse axis from '%s'\n", coord_and_axis); + LOG("Error: could not parse axis from '%s'\n", coord_and_axis); return NISSY_ERROR_INVALID_SOLVER; } @@ -316,8 +318,8 @@ solve_coord( }; if (coord->coord(c, coord_data) == 0) { - if (minmoves == 0 && !appendsolution( - &solution_moves, &solution_settings, &solution_list, true)) + if (minmoves == 0 && !appendsolution(&solution_moves, + &solution_settings, &solution_list, true, coord->name)) goto solve_coord_error_buffer; goto solve_coord_done; } @@ -327,18 +329,17 @@ solve_coord( !solutions_done(&solution_list, &solution_settings, d); d++ ) { - if (d >= 10) - LOG("Found %" PRIu64 " solutions, searching at depth %" - PRId8 "\n", solution_list.nsols, d); + if (d >= 12) + LOG("[%s solve] Found %" PRIu64 " solutions, " + "searching at depth %" PRId8 "\n", + coord->name, solution_list.nsols, d); arg.target_depth = d; solution_moves_reset(arg.solution_moves); ndepth = solve_coord_dfs(&arg); - if (ndepth < 0) { - LOG("Error %" PRId64 "\n", ndepth); + if (ndepth < 0) return ndepth; - } solution_list.nsols += (uint64_t)ndepth; } @@ -347,14 +348,15 @@ solve_coord_done: return (int64_t)solution_list.nsols; solve_coord_error_data: - LOG("solve_coord: error reading table\n"); + LOG("[%s solve] Error reading table\n", coord->name); return NISSY_ERROR_DATA; solve_coord_error_buffer: - LOG("Could not append solution to buffer: size too small\n"); + LOG("[%s solve] Error appending solution to buffer: size too small\n", + coord->name); return NISSY_ERROR_BUFFER_SIZE; solve_coord_error_unsolvable: - LOG("Cube not ready for solving %s\n", coord->name); + LOG("[%s solve] Error: cube not ready\n", coord->name); return NISSY_ERROR_UNSOLVABLE_CUBE; } diff --git a/src/solvers/coord/utils.h b/src/solvers/coord/utils.h index 5407de3..ef3f817 100644 --- a/src/solvers/coord/utils.h +++ b/src/solvers/coord/utils.h @@ -59,7 +59,7 @@ dataid_coord(const char *ca, char dataid[static NISSY_SIZE_DATAID]) parse_coord_and_axis(strlen(ca), ca, &c, NULL); if (c == NULL) { - LOG("dataid_coord: cannot parse coordinate from '%s'\n", ca); + LOG("Error: cannot parse coordinate from '%s'\n", ca); return NISSY_ERROR_INVALID_SOLVER; } -- cgit v1.3