Skip to content

Commit b080013

Browse files
jenshannoschwalmTurboGit
authored andcommitted
dt_print() maintenance and fixes
1. In database code the macros TRY_EXEC, TRY_STEP and TRY_PREPARE use dt_print() internally, the message strings all got the leading [init] and ending newlines stripped off, instead the macros take care of this. The leading [init] has been replaced by "TRY_EXEC" or the appropriate according to the macro for improved log quality. Also just one line per error with message and sql error string. Also at various places the log information for one problem appeared on several lines, fixed those. 2. dt_control_job_print() - now as static _control_job_print() - has been refactored and gets additional parameters to print "everything" instead of following a dt_print() without a newline. So - prettyfied logs pluse denser code. 3. Removed some overseen newlines or dots at the end of dt_print() 4. Spotted an unused inline function and commented it
1 parent c098ad5 commit b080013

File tree

10 files changed

+484
-521
lines changed

10 files changed

+484
-521
lines changed

src/bauhaus/bauhaus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ void dt_bauhaus_update_from_field(dt_iop_module_t *module,
12391239
default:
12401240
dt_print
12411241
(DT_DEBUG_ALWAYS,
1242-
"[dt_bauhaus_update_from_field] invalid bauhaus widget type encountered\n");
1242+
"[dt_bauhaus_update_from_field] invalid bauhaus widget type encountered");
12431243
}
12441244

12451245
// if gui->reset then notebook tab highlights were not yet changed

src/common/bilateralcl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ dt_bilateral_cl_t *dt_bilateral_init_cl(const int devid,
147147
}
148148

149149
#if 0
150-
fprintf(stderr, "[bilateral] created grid [%d %d %d]"
150+
dt_print(DT_DEBUG_ALWAYS, "[bilateral] created grid [%d %d %d]"
151151
" with sigma (%f %f) (%f %f)\n", b->size_x, b->size_y, b->size_z,
152152
b->sigma_s, sigma_s, b->sigma_r, sigma_r);
153153
#endif

src/common/camera_control.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,7 +1885,7 @@ int dt_camctl_camera_property_exists(const dt_camctl_t *c,
18851885
{
18861886
dt_print(DT_DEBUG_CAMCTL,
18871887
"[camera_control] failed to check if property exists"
1888-
" in camera configuration, camera == NULL\n");
1888+
" in camera configuration, camera == NULL");
18891889
return 0;
18901890
}
18911891

@@ -1895,7 +1895,7 @@ int dt_camctl_camera_property_exists(const dt_camctl_t *c,
18951895
{
18961896
dt_print(DT_DEBUG_CAMCTL,
18971897
"[camera_control] failed to check if property exists"
1898-
" in camera configuration, camera configuration == NULL\n");
1898+
" in camera configuration, camera configuration == NULL");
18991899
return 0;
19001900
}
19011901

@@ -1963,7 +1963,7 @@ const char *dt_camctl_camera_property_get_first_choice(const dt_camctl_t *c,
19631963
{
19641964
dt_print(DT_DEBUG_CAMCTL,
19651965
"[camera_control] failed to get first choice of property from camera,"
1966-
" camera==NULL\n");
1966+
" camera==NULL");
19671967
return NULL;
19681968
}
19691969
dt_camera_t *camera = (dt_camera_t *)cam;
@@ -1997,7 +1997,7 @@ const char *dt_camctl_camera_property_get_next_choice(const dt_camctl_t *c,
19971997
{
19981998
dt_print(DT_DEBUG_CAMCTL,
19991999
"[camera_control] Failed to get next choice of property from camera,"
2000-
" camera==NULL\n");
2000+
" camera==NULL");
20012001
return NULL;
20022002
}
20032003
dt_camera_t *camera = (dt_camera_t *)cam;

src/common/colorspaces.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,7 +2057,7 @@ void dt_colorspaces_set_display_profile
20572057
else
20582058
_update_display_profile(buffer, buffer_size, name, sizeof(name));
20592059
dt_print(DT_DEBUG_CONTROL, "[color profile] we got a new screen profile `%s'"
2060-
" from the %s (size: %d)\n",
2060+
" from the %s (size: %d)",
20612061
*name ? name : "(unknown)", profile_source, buffer_size);
20622062
}
20632063
else
@@ -2210,7 +2210,7 @@ dt_colorspaces_color_profile_type_t dt_colorspaces_cicp_to_type
22102210

22112211
if(filename != NULL)
22122212
dt_print(DT_DEBUG_IMAGEIO, "[colorin] unsupported CICP color profile"
2213-
" for `%s': %d/%d/%d\n", filename,
2213+
" for `%s': %d/%d/%d", filename,
22142214
cicp->color_primaries,
22152215
cicp->transfer_characteristics,
22162216
cicp->matrix_coefficients);

src/common/database.c

Lines changed: 439 additions & 461 deletions
Large diffs are not rendered by default.

src/common/pwstorage/pwstorage.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const dt_pwstorage_t *dt_pwstorage_new()
8787
_backend = PW_STORAGE_BACKEND_LIBSECRET;
8888
#endif
8989

90-
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] autodetected storage backend.");
90+
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] autodetected storage backend");
9191
}
9292
else if(strcmp(_backend_str, "none") == 0)
9393
_backend = PW_STORAGE_BACKEND_NONE;
@@ -109,28 +109,28 @@ const dt_pwstorage_t *dt_pwstorage_new()
109109
#endif
110110
else if(strcmp(_backend_str, "gnome keyring") == 0)
111111
{
112-
dt_print(DT_DEBUG_ALWAYS, "[pwstorage_new] GNOME Keyring backend is no longer supported.");
112+
dt_print(DT_DEBUG_ALWAYS, "[pwstorage_new] GNOME Keyring backend is no longer supported");
113113
dt_control_log(_("GNOME Keyring backend is no longer supported. configure a different one"));
114114
_backend = PW_STORAGE_BACKEND_NONE;
115115
}
116116

117117
switch(_backend)
118118
{
119119
default:
120-
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] unknown storage backend. Using none.");
120+
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] unknown storage backend. Using none");
121121
case PW_STORAGE_BACKEND_NONE:
122122
pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE;
123123
pwstorage->backend_context = NULL;
124124
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] no storage backend. not storing username/password. "
125-
"please change in preferences, security tab.\n");
125+
"please change in preferences, security tab");
126126
break;
127127
case PW_STORAGE_BACKEND_LIBSECRET:
128128
#ifdef HAVE_LIBSECRET
129-
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] using libsecret backend for username/password storage.");
129+
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] using libsecret backend for username/password storage");
130130
pwstorage->backend_context = (void *)dt_pwstorage_libsecret_new();
131131
if(pwstorage->backend_context == NULL)
132132
{
133-
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] error starting libsecret. using no storage backend.");
133+
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] error starting libsecret. using no storage backend");
134134
pwstorage->backend_context = NULL;
135135
pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE;
136136
}
@@ -141,17 +141,17 @@ const dt_pwstorage_t *dt_pwstorage_new()
141141
break;
142142
#else
143143
dt_print(DT_DEBUG_PWSTORAGE,
144-
"[pwstorage_new] libsecret backend not available. using no storage backend.");
144+
"[pwstorage_new] libsecret backend not available. using no storage backend");
145145
pwstorage->backend_context = NULL;
146146
pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE;
147147
#endif
148148
case PW_STORAGE_BACKEND_KWALLET:
149149
#ifdef HAVE_KWALLET
150-
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] using kwallet backend for username/password storage.");
150+
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] using kwallet backend for username/password storage");
151151
pwstorage->backend_context = (void *)dt_pwstorage_kwallet_new();
152152
if(pwstorage->backend_context == NULL)
153153
{
154-
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] error starting kwallet. using no storage backend.");
154+
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] error starting kwallet. using no storage backend");
155155
pwstorage->backend_context = NULL;
156156
pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE;
157157
}
@@ -163,30 +163,30 @@ const dt_pwstorage_t *dt_pwstorage_new()
163163
break;
164164
#else
165165
dt_print(DT_DEBUG_PWSTORAGE,
166-
"[pwstorage_new] kwallet backend not available. using no storage backend.");
166+
"[pwstorage_new] kwallet backend not available. using no storage backend");
167167
pwstorage->backend_context = NULL;
168168
pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE;
169169
#endif
170170
case PW_STORAGE_BACKEND_APPLE_KEYCHAIN:
171171
#ifdef HAVE_APPLE_KEYCHAIN
172-
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] using apple keychain backend for username/password storage.");
172+
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] using apple keychain backend for username/password storage");
173173
pwstorage->backend_context = (void *)dt_pwstorage_apple_keychain_new();
174174
pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_APPLE_KEYCHAIN;
175175
#else
176176
dt_print(DT_DEBUG_PWSTORAGE,
177-
"[pwstorage_new] apple keychain backend not available. using no storage backend.");
177+
"[pwstorage_new] apple keychain backend not available. using no storage backend");
178178
pwstorage->backend_context = NULL;
179179
pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE;
180180
#endif
181181
break;
182182
case PW_STORAGE_BACKEND_WINDOWS_CREDENTIALS:
183183
#ifdef HAVE_WINDOWS_CREDENTIALS
184-
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] using windows credentials backend for username/password storage.");
184+
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] using windows credentials backend for username/password storage");
185185
pwstorage->backend_context = (void *)dt_pwstorage_windows_credentials_new();
186186
pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_WINDOWS_CREDENTIALS;
187187
#else
188188
dt_print(DT_DEBUG_PWSTORAGE,
189-
"[pwstorage_new] windows credentials backend not available. using no storage backend.");
189+
"[pwstorage_new] windows credentials backend not available. using no storage backend");
190190
pwstorage->backend_context = NULL;
191191
pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE;
192192
#endif
@@ -253,7 +253,7 @@ gboolean dt_pwstorage_set(const gchar *slot, GHashTable *table)
253253
switch(darktable.pwstorage->pw_storage_backend)
254254
{
255255
case PW_STORAGE_BACKEND_NONE:
256-
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_set] no backend. not storing anything.");
256+
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_set] no backend. not storing anything");
257257
break;
258258
case PW_STORAGE_BACKEND_LIBSECRET:
259259
#if HAVE_LIBSECRET
@@ -289,7 +289,7 @@ GHashTable *dt_pwstorage_get(const gchar *slot)
289289
switch(darktable.pwstorage->pw_storage_backend)
290290
{
291291
case PW_STORAGE_BACKEND_NONE:
292-
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_get] no backend. not reading anything.");
292+
dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_get] no backend. not reading anything");
293293
break;
294294
case PW_STORAGE_BACKEND_LIBSECRET:
295295
#if HAVE_LIBSECRET

src/control/jobs.c

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,12 @@ void dt_control_job_set_state_callback(_dt_job_t *job, dt_job_state_change_callb
186186
job->state_changed_cb = cb;
187187
}
188188

189-
190-
static void dt_control_job_print(_dt_job_t *job)
189+
// We don't want to log dt_get_wtime() as we already show the stamp
190+
static void _control_job_print(_dt_job_t *job, const char *info, const char *err, int32_t res)
191191
{
192192
if(!job) return;
193-
dt_print(DT_DEBUG_CONTROL, "%s | queue: %d | priority: %d", job->description, job->queue, job->priority);
193+
dt_print(DT_DEBUG_CONTROL, "[%s]\t%02d %s %s | queue: %d | priority: %d",
194+
info, res, err, job->description, job->queue, job->priority);
194195
}
195196

196197
void dt_control_job_cancel(_dt_job_t *job)
@@ -213,7 +214,7 @@ void dt_control_job_wait(_dt_job_t *job)
213214
g_usleep(100000); // wait 0.1 seconds
214215
state = dt_control_job_get_state(job);
215216
}
216-
217+
217218
/* if job execution is not finished let's wait for it */
218219
if(state == DT_JOB_STATE_RUNNING || state == DT_JOB_STATE_CANCELLED)
219220
{
@@ -246,19 +247,15 @@ static gboolean _control_run_job_res(dt_control_t *control, int32_t res)
246247
dt_pthread_mutex_lock(&job->wait_mutex);
247248
if(dt_control_job_get_state(job) == DT_JOB_STATE_QUEUED)
248249
{
249-
dt_print(DT_DEBUG_CONTROL, "[run_job+] %02d %f ", res, dt_get_wtime());
250-
dt_control_job_print(job);
251-
dt_print(DT_DEBUG_CONTROL, "\n");
250+
_control_job_print(job, "run_job+", "", res);
252251

253252
_control_job_set_state(job, DT_JOB_STATE_RUNNING);
254253

255254
/* execute job */
256255
job->result = job->execute(job);
257256

258257
_control_job_set_state(job, DT_JOB_STATE_FINISHED);
259-
dt_print(DT_DEBUG_CONTROL, "[run_job-] %02d %f ", res, dt_get_wtime());
260-
dt_control_job_print(job);
261-
dt_print(DT_DEBUG_CONTROL, "\n");
258+
_control_job_print(job, "run_job-", "", res);
262259
}
263260
dt_pthread_mutex_unlock(&job->wait_mutex);
264261
dt_control_job_dispose(job);
@@ -330,22 +327,15 @@ static _dt_job_t *_control_schedule_job(dt_control_t *control)
330327

331328
static void _control_job_execute(_dt_job_t *job)
332329
{
333-
dt_print(DT_DEBUG_CONTROL, "[run_job+] %02d %f ", DT_CTL_WORKER_RESERVED + dt_control_get_threadid(),
334-
dt_get_wtime());
335-
dt_control_job_print(job);
336-
dt_print_nts(DT_DEBUG_CONTROL, "\n");
330+
_control_job_print(job, "run_job+", "", DT_CTL_WORKER_RESERVED + dt_control_get_threadid());
337331

338332
_control_job_set_state(job, DT_JOB_STATE_RUNNING);
339333

340334
/* execute job */
341335
job->result = job->execute(job);
342336

343337
_control_job_set_state(job, DT_JOB_STATE_FINISHED);
344-
345-
dt_print(DT_DEBUG_CONTROL, "[run_job-] %02d %f ", DT_CTL_WORKER_RESERVED + dt_control_get_threadid(),
346-
dt_get_wtime());
347-
dt_control_job_print(job);
348-
dt_print_nts(DT_DEBUG_CONTROL, "\n");
338+
_control_job_print(job, "run_job-", "", DT_CTL_WORKER_RESERVED + dt_control_get_threadid());
349339
}
350340

351341
static gboolean _control_run_job(dt_control_t *control)
@@ -394,8 +384,7 @@ gboolean dt_control_add_job_res(dt_control_t *control,
394384
}
395385

396386
dt_print(DT_DEBUG_CONTROL, "[add_job_res] %d | ", res);
397-
dt_control_job_print(job);
398-
dt_print_nts(DT_DEBUG_CONTROL, "\n");
387+
_control_job_print(job, "add_job_res", "", res);
399388

400389
_control_job_set_state(job, DT_JOB_STATE_QUEUED);
401390
control->job_res[res] = job;
@@ -441,9 +430,7 @@ gboolean dt_control_add_job(dt_control_t *control,
441430
GList **queue = &control->queues[queue_id];
442431
size_t length = control->queue_length[queue_id];
443432

444-
dt_print(DT_DEBUG_CONTROL, "[add_job] %zu | ", length);
445-
dt_control_job_print(job);
446-
dt_print_nts(DT_DEBUG_CONTROL, "\n");
433+
_control_job_print(job, "add_job", "", (int32_t)length);
447434

448435
if(queue_id == DT_JOB_QUEUE_SYSTEM_FG)
449436
{
@@ -456,9 +443,7 @@ gboolean dt_control_add_job(dt_control_t *control,
456443
_dt_job_t *other_job = (_dt_job_t *)control->job[k];
457444
if(_control_job_equal(job, other_job))
458445
{
459-
dt_print(DT_DEBUG_CONTROL, "[add_job] found job already in scheduled: ");
460-
dt_control_job_print(other_job);
461-
dt_print_nts(DT_DEBUG_CONTROL, "\n");
446+
_control_job_print(other_job, "add_job", "found job already in scheduled:", -1);
462447

463448
dt_pthread_mutex_unlock(&control->queue_mutex);
464449

@@ -475,9 +460,7 @@ gboolean dt_control_add_job(dt_control_t *control,
475460
_dt_job_t *other_job = (_dt_job_t *)iter->data;
476461
if(_control_job_equal(job, other_job))
477462
{
478-
dt_print(DT_DEBUG_CONTROL, "[add_job] found job already in queue: ");
479-
dt_control_job_print(other_job);
480-
dt_print_nts(DT_DEBUG_CONTROL, "\n");
463+
_control_job_print(other_job, "add_job", "found job already in queue", -1);
481464

482465
*queue = g_list_delete_link(*queue, iter);
483466
length--;

src/develop/develop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,7 @@ void dt_dev_read_history_ext(dt_develop_t *dev,
19211921

19221922
dt_print(DT_DEBUG_PARAMS,
19231923
"[dt_dev_read_history_ext] temporary history initialised with"
1924-
" default params and presets\n");
1924+
" default params and presets");
19251925

19261926
// Now merge memory.history into main.history
19271927

src/develop/imageop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1978,7 +1978,7 @@ gboolean _iop_validate_params(dt_introspection_field_t *field,
19781978
{
19791979
if(report)
19801980
dt_print(DT_DEBUG_ALWAYS, "[iop_validate_params] `%s' failed"
1981-
" for type \"%s\", for array element \"%d\"\n",
1981+
" for type \"%s\", for array element \"%d\"",
19821982
name, field->header.type_name, i);
19831983
all_ok = FALSE;
19841984
break;

src/develop/masks.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -968,14 +968,14 @@ static inline gboolean _dt_masks_intbuf_growto(dt_masks_intbuf_t *a,
968968
{
969969
// not much we can do here except emit an error message
970970
dt_print(DT_DEBUG_ALWAYS,
971-
"critical: out of memory for intbuf '%s' with size request %zu!\n",
971+
"critical: out of memory for intbuf '%s' with size request %zu!",
972972
a->tag, newsize);
973973
return FALSE;
974974
}
975975
if (a->buffer)
976976
{
977977
memcpy(newbuf, a->buffer, a->size * sizeof(int));
978-
dt_print(DT_DEBUG_MASKS, "[masks intbuf '%s'] grows to size %lu (is %p, was %p)\n",
978+
dt_print(DT_DEBUG_MASKS, "[masks intbuf '%s'] grows to size %lu (is %p, was %p)",
979979
a->tag,
980980
(unsigned long)a->size, newbuf, a->buffer);
981981
dt_free_align(a->buffer);
@@ -997,7 +997,7 @@ dt_masks_intbuf_t *dt_masks_intbuf_init(const size_t size, const char *tag)
997997
g_strlcpy(a->tag, tag, sizeof(a->tag)); //only for debugging purposes
998998
a->pos = 0;
999999
if(_dt_masks_intbuf_growto(a, size))
1000-
dt_print(DT_DEBUG_MASKS, "[masks intbuf '%s'] with initial size %lu (is %p)\n",
1000+
dt_print(DT_DEBUG_MASKS, "[masks intbuf '%s'] with initial size %lu (is %p)",
10011001
a->tag,
10021002
(unsigned long)a->size, a->buffer);
10031003
if(a->buffer == NULL)
@@ -1035,13 +1035,14 @@ static inline
10351035
void dt_masks_intbuf_free(dt_masks_intbuf_t *a)
10361036
{
10371037
if(a == NULL) return;
1038-
dt_print(DT_DEBUG_MASKS, "[masks intbuf '%s'] freed (was %p)\n", a->tag,
1038+
dt_print(DT_DEBUG_MASKS, "[masks intbuf '%s'] freed (was %p)", a->tag,
10391039
a->buffer);
10401040
dt_free_align(a->buffer);
10411041
free(a);
10421042
}
10431043

10441044
// Dump buffer to file for debugging.
1045+
/*
10451046
static inline
10461047
void dt_masks_intnbuf_debug_print(dt_masks_intbuf_t *a)
10471048
{
@@ -1056,6 +1057,7 @@ void dt_masks_intnbuf_debug_print(dt_masks_intbuf_t *a)
10561057
}
10571058
fclose(f);
10581059
}
1060+
*/
10591061

10601062
/* End of dynamic buffer code
10611063
******************************************************/

0 commit comments

Comments
 (0)