Logging: use __func__

This commit is contained in:
Shahram Najm 2023-08-14 16:52:22 +01:00
parent ff017ff2bc
commit e5ed453395
1 changed files with 25 additions and 25 deletions

View File

@ -625,8 +625,8 @@ static int check_geometry(grib_handle* handle, const grib_util_grid_spec* spec,
strcpy(msg, "Specified to be global (in spec)");
sum = sum_of_pl_array(spec->pl, spec->pl_size);
if (sum != data_values_count) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Invalid reduced gaussian grid: %s but data_values_count != sum_of_pl_array (%zu!=%zu)\n",
msg, data_values_count, sum);
fprintf(stderr, "%s: Invalid reduced gaussian grid: %s but data_values_count != sum_of_pl_array (%zu!=%zu)\n",
__func__, msg, data_values_count, sum);
return GRIB_WRONG_GRID;
}
}
@ -874,7 +874,7 @@ static int get_grib_sample_name(grib_handle* h, long editionNumber,
if (spec->pl && spec->grid_name) {
/* Cannot have BOTH pl and grid name specified */
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Cannot set BOTH spec.pl and spec.grid_name!\n");
fprintf(stderr, "%s: Cannot set BOTH spec.pl and spec.grid_name!\n", __func__);
return GRIB_INTERNAL_ERROR;
}
if (spec->grid_name) {
@ -1005,7 +1005,7 @@ grib_handle* grib_util_set_spec(grib_handle* h,
grid_type = get_grid_type_name(spec->grid_type);
if (!grid_type) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Unknown spec.grid_type (%d)\n", spec->grid_type);
fprintf(stderr, "%s: Unknown spec.grid_type (%d)\n", __func__, spec->grid_type);
*err = GRIB_NOT_IMPLEMENTED;
return NULL;
}
@ -1279,7 +1279,7 @@ grib_handle* grib_util_set_spec(grib_handle* h,
setSecondOrder = 1;
break;
default:
fprintf(stderr, "GRIB_UTIL_SET_SPEC: invalid packing_spec.packing_type (%ld)\n", packing_spec->packing_type);
fprintf(stderr, "%s: invalid packing_spec.packing_type (%ld)\n", __func__, packing_spec->packing_type);
*err = GRIB_INTERNAL_ERROR;
goto cleanup;
break;
@ -1342,7 +1342,7 @@ grib_handle* grib_util_set_spec(grib_handle* h,
break;
default:
fprintf(stderr, "GRIB_UTIL_SET_SPEC: invalid packing_spec.accuracy (%ld)\n", packing_spec->accuracy);
fprintf(stderr, "%s: invalid packing_spec.accuracy (%ld)\n", __func__, packing_spec->accuracy);
grib_handle_delete(h_sample);
*err = GRIB_INTERNAL_ERROR;
goto cleanup;
@ -1383,26 +1383,26 @@ grib_handle* grib_util_set_spec(grib_handle* h,
/* GRIB-857: Set "pl" array if provided (For reduced Gaussian grids) */
Assert(spec->pl_size >= 0);
if (spec->pl && spec->pl_size == 0) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: pl array not NULL but pl_size == 0!\n");
fprintf(stderr, "%s: pl array not NULL but pl_size == 0!\n", __func__);
goto cleanup;
}
if (spec->pl_size > 0 && spec->pl == NULL) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: pl_size not zero but pl array == NULL!\n");
fprintf(stderr, "%s: pl_size not zero but pl array == NULL!\n", __func__);
goto cleanup;
}
if (spec->pl_size != 0 && (spec->grid_type == GRIB_UTIL_GRID_SPEC_REDUCED_GG || spec->grid_type == GRIB_UTIL_GRID_SPEC_REDUCED_ROTATED_GG)) {
*err = grib_set_long_array(h_out, "pl", spec->pl, spec->pl_size);
if (*err) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Cannot set pl: %s\n", grib_get_error_message(*err));
fprintf(stderr, "%s: Cannot set pl: %s\n", __func__, grib_get_error_message(*err));
goto cleanup;
}
if (global_grid) {
size_t sum = sum_of_pl_array(spec->pl, spec->pl_size);
if (data_values_count != sum) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: invalid reduced gaussian grid: "
fprintf(stderr, "%s: invalid reduced gaussian grid: "
"specified as global, data_values_count=%zu but sum of pl array=%zu\n",
data_values_count, sum);
__func__, data_values_count, sum);
*err = GRIB_WRONG_GRID;
goto cleanup;
}
@ -1418,7 +1418,7 @@ grib_handle* grib_util_set_spec(grib_handle* h,
/* Apply adjustments to bounding box if needed */
if (expandBoundingBox) {
if ((*err = expand_bounding_box(h_out, values, count)) != 0) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Cannot expand bounding box: %s\n", grib_get_error_message(*err));
fprintf(stderr, "%s: Cannot expand bounding box: %s\n", __func__, grib_get_error_message(*err));
if (h->context->write_on_fail)
grib_write_message(h_out, "error.grib", "w");
goto cleanup;
@ -1428,13 +1428,13 @@ grib_handle* grib_util_set_spec(grib_handle* h,
if (convertEditionEarlier && packing_spec->editionNumber > 1) {
*err = grib_set_long(h_out, "edition", packing_spec->editionNumber);
if (*err) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Cannot convert to edition %ld.\n", packing_spec->editionNumber);
fprintf(stderr, "%s: Cannot convert to edition %ld.\n", __func__, packing_spec->editionNumber);
goto cleanup;
}
}
if ((*err = grib_set_values(h_out, values, count)) != 0) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Cannot set key values: %s\n", grib_get_error_message(*err));
fprintf(stderr, "%s: Cannot set key values: %s\n", __func__, grib_get_error_message(*err));
for (i = 0; i < count; i++)
if (values[i].error) fprintf(stderr, " %s %s\n", values[i].name, grib_get_error_message(values[i].error));
goto cleanup;
@ -1461,11 +1461,11 @@ grib_handle* grib_util_set_spec(grib_handle* h,
/* GRIB-863: must set increments to MISSING */
/* increments are not coded in message but computed */
if ((*err = grib_set_missing(h_out, "iDirectionIncrement")) != 0) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Cannot set Di to missing: %s\n", grib_get_error_message(*err));
fprintf(stderr, "%s: Cannot set Di to missing: %s\n", __func__, grib_get_error_message(*err));
goto cleanup;
}
if ((*err = grib_set_missing(h_out, "jDirectionIncrement")) != 0) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Cannot set Dj to missing: %s\n", grib_get_error_message(*err));
fprintf(stderr, "%s: Cannot set Dj to missing: %s\n", __func__, grib_get_error_message(*err));
goto cleanup;
}
}
@ -1502,7 +1502,7 @@ grib_handle* grib_util_set_spec(grib_handle* h,
grib_set_string(h_out, "packingType", "grid_second_order", &slen);
*err = grib_set_double_array(h_out, "values", data_values, data_values_count);
if (*err != GRIB_SUCCESS) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: setting data values failed: %s\n", grib_get_error_message(*err));
fprintf(stderr, "%s: setting data values failed: %s\n", __func__, grib_get_error_message(*err));
goto cleanup;
}
}
@ -1519,8 +1519,8 @@ grib_handle* grib_util_set_spec(grib_handle* h,
if (packing_spec->editionNumber && packing_spec->editionNumber != editionNumber) {
*err = grib_set_long(h_out, "edition", packing_spec->editionNumber);
if (*err != GRIB_SUCCESS) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Failed to change edition to %ld: %s\n",
packing_spec->editionNumber, grib_get_error_message(*err));
fprintf(stderr, "%s: Failed to change edition to %ld: %s\n",
__func__, packing_spec->editionNumber, grib_get_error_message(*err));
if (h->context->write_on_fail)
grib_write_message(h_out, "error.grib", "w");
goto cleanup;
@ -1532,16 +1532,16 @@ grib_handle* grib_util_set_spec(grib_handle* h,
if (setJpegPacking == 1) {
*err = grib_set_string(h_out, "packingType", "grid_jpeg", &slen);
if (*err != GRIB_SUCCESS) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Failed to change packingType to JPEG: %s\n",
grib_get_error_message(*err));
fprintf(stderr, "%s: Failed to change packingType to JPEG: %s\n",
__func__, grib_get_error_message(*err));
goto cleanup;
}
}
if (setCcsdsPacking == 1) {
*err = grib_set_string(h_out, "packingType", "grid_ccsds", &slen);
if (*err != GRIB_SUCCESS) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Failed to change packingType to CCSDS: %s\n",
grib_get_error_message(*err));
fprintf(stderr, "%s: Failed to change packingType to CCSDS: %s\n",
__func__, grib_get_error_message(*err));
goto cleanup;
}
}
@ -1557,7 +1557,7 @@ grib_handle* grib_util_set_spec(grib_handle* h,
}
if ((*err = check_geometry(h_out, spec, data_values_count, global_grid)) != GRIB_SUCCESS) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Geometry check failed: %s\n", grib_get_error_message(*err));
fprintf(stderr, "%s: Geometry check failed: %s\n", __func__, grib_get_error_message(*err));
if (h->context->write_on_fail)
grib_write_message(h_out, "error.grib", "w");
goto cleanup;
@ -1573,7 +1573,7 @@ grib_handle* grib_util_set_spec(grib_handle* h,
// goto cleanup;
// }
if (h->context->debug == -1) fprintf(stderr, "ECCODES DEBUG grib_util: grib_util_set_spec end\n");
if (h->context->debug == -1) fprintf(stderr, "ECCODES DEBUG grib_util: %s end\n",__func__);
return h_out;