Skip to content

Commit

Permalink
Refactor dt_print to add newline automatically
Browse files Browse the repository at this point in the history
Leaving out the burden thinking about a newline while using dt_print()

Original work done by @dterrahe

While being here and touching all those files, ensure all log message lines don't end
with a dot. (so far most did not, some did, and some even had a dot after an exclamation mark)

Nothing "big" but still worthwhile
  • Loading branch information
jenshannoschwalm committed Oct 20, 2024
1 parent a64c1c5 commit 8a312fb
Show file tree
Hide file tree
Showing 196 changed files with 1,563 additions and 1,571 deletions.
22 changes: 11 additions & 11 deletions src/bauhaus/bauhaus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ void dt_bauhaus_widget_set_field(GtkWidget *widget,
if(*w->label)
dt_print(DT_DEBUG_ALWAYS,
"[dt_bauhaus_widget_set_field] bauhaus label '%s'"
" set before field (needs to be after)\n",
" set before field (needs to be after)",
w->label);
w->field = field;
w->field_type = field_type;
Expand Down Expand Up @@ -1213,7 +1213,7 @@ void dt_bauhaus_update_from_field(dt_iop_module_t *module,
break;
default:
dt_print(DT_DEBUG_ALWAYS,
"[dt_bauhaus_update_from_field] unsupported slider data type\n");
"[dt_bauhaus_update_from_field] unsupported slider data type");
}
break;
case DT_BAUHAUS_COMBOBOX:
Expand All @@ -1233,7 +1233,7 @@ void dt_bauhaus_update_from_field(dt_iop_module_t *module,
break;
default:
dt_print(DT_DEBUG_ALWAYS,
"[dt_bauhaus_update_from_field] unsupported combo data type\n");
"[dt_bauhaus_update_from_field] unsupported combo data type");
}
break;
default:
Expand Down Expand Up @@ -1769,7 +1769,7 @@ static void _combobox_set(dt_bauhaus_widget_t *w,
if(*b != prevb) dt_iop_gui_changed(w->module, GTK_WIDGET(w), &prevb);
break;
default:
dt_print(DT_DEBUG_ALWAYS, "[_combobox_set] unsupported combo data type\n");
dt_print(DT_DEBUG_ALWAYS, "[_combobox_set] unsupported combo data type");
}
}
_highlight_changed_notebook_tab(GTK_WIDGET(w),
Expand Down Expand Up @@ -1905,7 +1905,7 @@ void dt_bauhaus_slider_set_stop(GtkWidget *widget,
else
{
dt_print(DT_DEBUG_ALWAYS,
"[bauhaus_slider_set_stop] only %d stops allowed.\n",
"[bauhaus_slider_set_stop] only %d stops allowed",
DT_BAUHAUS_SLIDER_MAX_STOPS);
}
}
Expand Down Expand Up @@ -3230,7 +3230,7 @@ static void _slider_value_change(dt_bauhaus_widget_t *w)
break;
default:
dt_print(DT_DEBUG_ALWAYS,
"[_slider_value_change] unsupported slider data type\n");
"[_slider_value_change] unsupported slider data type");
}
}

Expand Down Expand Up @@ -3554,15 +3554,15 @@ void dt_bauhaus_vimkey_exec(const char *input)
case DT_BAUHAUS_SLIDER:
old_value = dt_bauhaus_slider_get(w);
new_value = dt_calculator_solve(old_value, input);
dt_print(DT_DEBUG_ALWAYS, " = %f\n", new_value);
dt_print(DT_DEBUG_ALWAYS, " = %f", new_value);
if(dt_isfinite(new_value))
dt_bauhaus_slider_set(w, new_value);
break;
case DT_BAUHAUS_COMBOBOX:
// TODO: what about text as entry?
old_value = dt_bauhaus_combobox_get(w);
new_value = dt_calculator_solve(old_value, input);
dt_print(DT_DEBUG_ALWAYS, " = %f\n", new_value);
dt_print(DT_DEBUG_ALWAYS, " = %f", new_value);
if(dt_isfinite(new_value))
dt_bauhaus_combobox_set(w, new_value);
break;
Expand Down Expand Up @@ -3673,7 +3673,7 @@ static float _action_process_slider(gpointer target,
break;
default:
dt_print(DT_DEBUG_ALWAYS,
"[_action_process_slider] unknown shortcut effect (%d) for slider\n",
"[_action_process_slider] unknown shortcut effect (%d) for slider",
effect);
break;
}
Expand Down Expand Up @@ -3710,7 +3710,7 @@ static float _action_process_slider(gpointer target,
break;
default:
dt_print(DT_DEBUG_ALWAYS,
"[_action_process_slider] unknown shortcut effect (%d) for slider\n",
"[_action_process_slider] unknown shortcut effect (%d) for slider",
effect);
break;
}
Expand All @@ -3719,7 +3719,7 @@ static float _action_process_slider(gpointer target,
break;
default:
dt_print(DT_DEBUG_ALWAYS,
"[_action_process_slider] unknown shortcut element (%d) for slider\n",
"[_action_process_slider] unknown shortcut element (%d) for slider",
element);
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/common/act_on.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ gboolean _cache_update(const gboolean only_visible,
for(GList *ll = l;
ll;
ll = g_list_next(ll)) dt_util_str_cat(&tx, "%d ", GPOINTER_TO_INT(ll->data));
dt_print(DT_DEBUG_ACT_ON, "%s\n", tx);
dt_print(DT_DEBUG_ACT_ON, "%s", tx);
g_free(tx);
}

Expand Down Expand Up @@ -442,7 +442,7 @@ dt_imgid_t dt_act_on_get_main_image()
}

if((darktable.unmuted & DT_DEBUG_ACT_ON) == DT_DEBUG_ACT_ON)
dt_print(DT_DEBUG_ACT_ON, "[images to act on] single image : %d\n", ret);
dt_print(DT_DEBUG_ACT_ON, "[images to act on] single image : %d", ret);

return ret;
}
Expand Down
8 changes: 4 additions & 4 deletions src/common/bilateral.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ void dt_bilateral_grid_size(dt_bilateral_t *b,
#if 0
if(b->sigma_s != sigma_s)
dt_print(DT_DEBUG_ALWAYS,
"[bilateral] clamped sigma_s (%g -> %g)!\n",sigma_s,b->sigma_s);
"[bilateral] clamped sigma_s (%g -> %g)!",sigma_s,b->sigma_s);
if(b->sigma_r != sigma_r)
dt_print(DT_DEBUG_ALWAYS,
"[bilateral] clamped sigma_r (%g -> %g)!\n",sigma_r,b->sigma_r);
"[bilateral] clamped sigma_r (%g -> %g)!",sigma_r,b->sigma_r);
#endif
}

Expand Down Expand Up @@ -187,13 +187,13 @@ dt_bilateral_t *dt_bilateral_init(const int width, // width of input image
if(!b->buf)
{
dt_print(DT_DEBUG_ALWAYS,
"[bilateral] unable to allocate buffer for %zux%zux%zu grid\n",
"[bilateral] unable to allocate buffer for %zux%zux%zu grid",
b->size_x,b->size_y,b->size_z);
free(b);
return NULL;
}
dt_print(DT_DEBUG_DEV,
"[bilateral] created grid [%ld %ld %ld] with sigma (%f %f) (%f %f)\n",
"[bilateral] created grid [%ld %ld %ld] with sigma (%f %f) (%f %f)",
b->size_x, b->size_y, b->size_z, b->sigma_s, sigma_s, b->sigma_r, sigma_r);
return b;
}
Expand Down
4 changes: 2 additions & 2 deletions src/common/bilateralcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ dt_bilateral_cl_t *dt_bilateral_init_cl(const int devid,
if(!dt_opencl_local_buffer_opt(devid, darktable.opencl->bilateral->kernel_splat, &locopt))
{
dt_print(DT_DEBUG_OPENCL,
"[opencl_bilateral] can not identify resource limits for device %d in bilateral grid\n", devid);
"[opencl_bilateral] can not identify resource limits for device %d in bilateral grid", devid);
return NULL;
}

if(locopt.sizex * locopt.sizey < 16 * 16)
{
dt_print(DT_DEBUG_OPENCL,
"[opencl_bilateral] device %d does not offer sufficient resources to run bilateral grid\n",
"[opencl_bilateral] device %d does not offer sufficient resources to run bilateral grid",
devid);
return NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions src/common/box_filters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ void dt_box_mean_horizontal(float *const __restrict__ buf,
dt_free_align(scratch);
}
else
dt_print(DT_DEBUG_ALWAYS,"[box_mean] unable to allocate scratch memory\n");
dt_print(DT_DEBUG_ALWAYS, "[box_mean] unable to allocate scratch memory");
}
else if(ch == (9|BOXFILTER_KAHAN_SUM))
{
Expand All @@ -664,7 +664,7 @@ void dt_box_mean_horizontal(float *const __restrict__ buf,
dt_free_align(scratch);
}
else
dt_print(DT_DEBUG_ALWAYS,"[box_mean] unable to allocate scratch memory\n");
dt_print(DT_DEBUG_ALWAYS, "[box_mean] unable to allocate scratch memory");
}
else
dt_unreachable_codepath();
Expand Down
8 changes: 4 additions & 4 deletions src/common/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ dt_cache_entry_t *dt_cache_testget(dt_cache_t *cache,
dt_pthread_mutex_unlock(&cache->lock);
const double end = dt_get_debug_wtime();
if(end - start > 0.1)
dt_print(DT_DEBUG_ALWAYS, "try+ wait time %.06fs mode %c \n", end - start, mode);
dt_print(DT_DEBUG_ALWAYS, "try+ wait time %.06fs mode %c", end - start, mode);

if(mode == 'w')
{
Expand All @@ -149,7 +149,7 @@ dt_cache_entry_t *dt_cache_testget(dt_cache_t *cache,
dt_pthread_mutex_unlock(&cache->lock);
const double end = dt_get_debug_wtime();
if(end - start > 0.1)
dt_print(DT_DEBUG_ALWAYS, "try- wait time %.06fs\n", end - start);
dt_print(DT_DEBUG_ALWAYS, "try- wait time %.06fs", end - start);
return 0;
}

Expand Down Expand Up @@ -226,7 +226,7 @@ dt_cache_entry_t *dt_cache_get_with_caller(dt_cache_t *cache,
// here dies your 32-bit system:
dt_cache_entry_t *entry = (dt_cache_entry_t *)g_slice_alloc(sizeof(dt_cache_entry_t));
const int ret = dt_pthread_rwlock_init(&entry->lock, 0);
if(ret) dt_print(DT_DEBUG_ALWAYS, "rwlock init: %d\n", ret);
if(ret) dt_print(DT_DEBUG_ALWAYS, "rwlock init: %d", ret);

entry->data = 0;
entry->data_size = cache->entry_size;
Expand Down Expand Up @@ -264,7 +264,7 @@ dt_cache_entry_t *dt_cache_get_with_caller(dt_cache_t *cache,
dt_pthread_mutex_unlock(&cache->lock);
const double end = dt_get_debug_wtime();
if(end - start > 0.1)
dt_print(DT_DEBUG_ALWAYS, "wait time %.06fs\n", end - start);
dt_print(DT_DEBUG_ALWAYS, "wait time %.06fs", end - start);

// WARNING: do *NOT* unpoison here. it must be done by the caller!

Expand Down
Loading

0 comments on commit 8a312fb

Please sign in to comment.