mu: use g_printerr for errors, instead of g_warning

With the new logging setup, we need g_printerr
This commit is contained in:
Dirk-Jan C. Binnema
2020-06-11 22:16:36 +03:00
parent 9b2746dce5
commit 68533cee0d
6 changed files with 26 additions and 30 deletions

View File

@ -1,5 +1,5 @@
/* /*
** Copyright (C) 2011-2019 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2011-2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify it under ** This program is free software; you can redistribute it and/or modify it under
** the terms of the GNU General Public License as published by the Free Software ** the terms of the GNU General Public License as published by the Free Software
@ -368,7 +368,7 @@ run_cmd_cfind (const Mu::Store& store,
g_regex_unref (ecdata.rx); g_regex_unref (ecdata.rx);
if (ecdata.n == 0) { if (ecdata.n == 0) {
g_warning ("no matching contacts found"); g_printerr ("no matching contacts found\n");
return MU_ERROR_NO_MATCHES; return MU_ERROR_NO_MATCHES;
} }
@ -389,14 +389,14 @@ cfind_params_valid (const MuConfig *opts)
case MU_CONFIG_FORMAT_DEBUG: case MU_CONFIG_FORMAT_DEBUG:
break; break;
default: default:
g_warning ("invalid output format %s", g_printerr ("invalid output format %s\n",
opts->formatstr ? opts->formatstr : "<none>"); opts->formatstr ? opts->formatstr : "<none>");
return FALSE; return FALSE;
} }
/* only one pattern allowed */ /* only one pattern allowed */
if (opts->params[1] && opts->params[2]) { if (opts->params[1] && opts->params[2]) {
g_warning ("usage: mu cfind [options] [<ptrn>]"); g_printerr ("usage: mu cfind [options] [<ptrn>]\n");
return FALSE; return FALSE;
} }

View File

@ -55,7 +55,7 @@ save_part (MuMsg *msg, const char *targetdir, guint partidx, const MuConfig *opt
rv = TRUE; rv = TRUE;
exit: exit:
if (err) { if (err) {
g_warning ("error with MIME-part: %s", err->message); g_printerr ("error with MIME-part: %s\n", err->message);
g_clear_error (&err); g_clear_error (&err);
} }
@ -81,13 +81,13 @@ save_numbered_parts (MuMsg *msg, const MuConfig *opts)
idx = (unsigned)(i = strtol (*cur, &endptr, 10)); idx = (unsigned)(i = strtol (*cur, &endptr, 10));
if (i < 0 || *cur == endptr) { if (i < 0 || *cur == endptr) {
g_warning ("invalid MIME-part index '%s'", *cur); g_printerr ("invalid MIME-part index '%s'\n", *cur);
rv = FALSE; rv = FALSE;
break; break;
} }
if (!save_part (msg, opts->targetdir, idx, opts)) { if (!save_part (msg, opts->targetdir, idx, opts)) {
g_warning ("failed to save MIME-part %d", idx); g_printerr ("failed to save MIME-part %d\n", idx);
rv = FALSE; rv = FALSE;
break; break;
} }
@ -118,8 +118,8 @@ anchored_regex (const char* pattern)
g_free (anchored); g_free (anchored);
if (!rx) { if (!rx) {
g_warning ("error in regular expression '%s': %s", g_printerr ("error in regular expression '%s': %s\n",
pattern, err->message ? err->message : "error"); pattern, err->message ? err->message : "error");
g_error_free (err); g_error_free (err);
return NULL; return NULL;
} }
@ -146,7 +146,7 @@ save_part_with_filename (MuMsg *msg, const char *pattern, const MuConfig *opts)
lst = mu_msg_find_files (msg, msgopts, rx); lst = mu_msg_find_files (msg, msgopts, rx);
g_regex_unref (rx); g_regex_unref (rx);
if (!lst) { if (!lst) {
g_warning ("no matching attachments found"); g_printerr ("no matching attachments found");
return FALSE; return FALSE;
} }
@ -219,7 +219,7 @@ save_part_if (MuMsg *msg, MuMsgPart *part, SaveData *sd)
++sd->saved_num; ++sd->saved_num;
exit: exit:
if (err) if (err)
g_warning ("error saving MIME part: %s", err->message); g_printerr ("error saving MIME part: %s", err->message);
g_free (filepath); g_free (filepath);
g_clear_error (&err); g_clear_error (&err);
@ -243,8 +243,8 @@ save_certain_parts (MuMsg *msg, const MuConfig *opts)
(MuMsgPartForeachFunc)save_part_if, &sd); (MuMsgPartForeachFunc)save_part_if, &sd);
if (sd.saved_num == 0) { if (sd.saved_num == 0) {
g_warning ("no %s extracted from this message", g_printerr ("no %s extracted from this message",
opts->save_attachments ? "attachments" : "parts"); opts->save_attachments ? "attachments" : "parts");
sd.result = FALSE; sd.result = FALSE;
} }
@ -263,7 +263,7 @@ save_parts (const char *path, const char *filename, const MuConfig *opts)
msg = mu_msg_new_from_file (path, NULL, &err); msg = mu_msg_new_from_file (path, NULL, &err);
if (!msg) { if (!msg) {
if (err) { if (err) {
g_warning ("error: %s", err->message); g_printerr ("error: %s", err->message);
g_error_free (err); g_error_free (err);
} }
return FALSE; return FALSE;

View File

@ -411,8 +411,8 @@ thread_indent (MuMsgIter *iter)
ti = mu_msg_iter_get_thread_info (iter); ti = mu_msg_iter_get_thread_info (iter);
if (!ti) { if (!ti) {
g_warning ("cannot get thread-info for message %u", g_printerr ("cannot get thread-info for message %u\n",
mu_msg_iter_get_docid (iter)); mu_msg_iter_get_docid (iter));
return; return;
} }

View File

@ -38,13 +38,11 @@ static gboolean MU_CAUGHT_SIGNAL;
static void static void
sig_handler (int sig) sig_handler (int sig)
{ {
if (!MU_CAUGHT_SIGNAL && sig == SIGINT) { /* Ctrl-C */ if (!MU_CAUGHT_SIGNAL && sig == SIGINT) /* Ctrl-C */
g_print ("\n"); g_print ("\nshutting down gracefully, "
g_warning ("shutting down gracefully, "
"press again to kill immediately"); "press again to kill immediately");
}
MU_CAUGHT_SIGNAL = TRUE; MU_CAUGHT_SIGNAL = TRUE;
} }
static void static void

View File

@ -75,13 +75,11 @@ install_sig_handler (void)
sigs[i], g_strerror (errno));; sigs[i], g_strerror (errno));;
} }
/* /*
* Markers for/after the length cookie that precedes the expression we write to * Markers for/after the length cookie that precedes the expression we write to
* output. We use octal 376, 377 (ie, 0xfe, 0xff) as they will never occur in * output. We use octal 376, 377 (ie, 0xfe, 0xff) as they will never occur in
* utf8 */ * utf8 */
#define COOKIE_PRE '\376' #define COOKIE_PRE '\376'
#define COOKIE_POST '\377' #define COOKIE_POST '\377'

View File

@ -302,13 +302,13 @@ static gboolean
check_file_okay (const char *path, gboolean cmd_add) check_file_okay (const char *path, gboolean cmd_add)
{ {
if (!g_path_is_absolute (path)) { if (!g_path_is_absolute (path)) {
g_warning ("path is not absolute: %s", path); g_printerr ("path is not absolute: %s\n", path);
return FALSE; return FALSE;
} }
if (cmd_add && access(path, R_OK) != 0) { if (cmd_add && access(path, R_OK) != 0) {
g_warning ("path is not readable: %s: %s", g_printerr ("path is not readable: %s: %s\n",
path, strerror (errno)); path, strerror (errno));
return FALSE; return FALSE;
} }
@ -341,14 +341,14 @@ foreach_msg_file (Mu::Store& store, const MuConfig *opts,
if (!check_file_okay (path, TRUE)) { if (!check_file_okay (path, TRUE)) {
all_ok = FALSE; all_ok = FALSE;
g_warning ("not a valid message file: %s", path); g_printerr ("not a valid message file: %s\n", path);
continue; continue;
} }
if (!foreach_func (store, path, err)) { if (!foreach_func (store, path, err)) {
all_ok = FALSE; all_ok = FALSE;
g_warning ("error with %s: %s", path, g_printerr ("error with %s: %s\n", path,
(err&&*err) ? (*err)->message : (err&&*err) ? (*err)->message :
"something went wrong"); "something went wrong");
g_clear_error (err); g_clear_error (err);
continue; continue;