mu: use g_printerr for errors, instead of g_warning
With the new logging setup, we need g_printerr
This commit is contained in:
@ -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
|
||||
** 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);
|
||||
|
||||
if (ecdata.n == 0) {
|
||||
g_warning ("no matching contacts found");
|
||||
g_printerr ("no matching contacts found\n");
|
||||
return MU_ERROR_NO_MATCHES;
|
||||
}
|
||||
|
||||
@ -389,14 +389,14 @@ cfind_params_valid (const MuConfig *opts)
|
||||
case MU_CONFIG_FORMAT_DEBUG:
|
||||
break;
|
||||
default:
|
||||
g_warning ("invalid output format %s",
|
||||
opts->formatstr ? opts->formatstr : "<none>");
|
||||
g_printerr ("invalid output format %s\n",
|
||||
opts->formatstr ? opts->formatstr : "<none>");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* only one pattern allowed */
|
||||
if (opts->params[1] && opts->params[2]) {
|
||||
g_warning ("usage: mu cfind [options] [<ptrn>]");
|
||||
g_printerr ("usage: mu cfind [options] [<ptrn>]\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ save_part (MuMsg *msg, const char *targetdir, guint partidx, const MuConfig *opt
|
||||
rv = TRUE;
|
||||
exit:
|
||||
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);
|
||||
}
|
||||
|
||||
@ -81,13 +81,13 @@ save_numbered_parts (MuMsg *msg, const MuConfig *opts)
|
||||
|
||||
idx = (unsigned)(i = strtol (*cur, &endptr, 10));
|
||||
if (i < 0 || *cur == endptr) {
|
||||
g_warning ("invalid MIME-part index '%s'", *cur);
|
||||
g_printerr ("invalid MIME-part index '%s'\n", *cur);
|
||||
rv = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
break;
|
||||
}
|
||||
@ -118,8 +118,8 @@ anchored_regex (const char* pattern)
|
||||
g_free (anchored);
|
||||
|
||||
if (!rx) {
|
||||
g_warning ("error in regular expression '%s': %s",
|
||||
pattern, err->message ? err->message : "error");
|
||||
g_printerr ("error in regular expression '%s': %s\n",
|
||||
pattern, err->message ? err->message : "error");
|
||||
g_error_free (err);
|
||||
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);
|
||||
g_regex_unref (rx);
|
||||
if (!lst) {
|
||||
g_warning ("no matching attachments found");
|
||||
g_printerr ("no matching attachments found");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ save_part_if (MuMsg *msg, MuMsgPart *part, SaveData *sd)
|
||||
++sd->saved_num;
|
||||
exit:
|
||||
if (err)
|
||||
g_warning ("error saving MIME part: %s", err->message);
|
||||
g_printerr ("error saving MIME part: %s", err->message);
|
||||
|
||||
g_free (filepath);
|
||||
g_clear_error (&err);
|
||||
@ -243,8 +243,8 @@ save_certain_parts (MuMsg *msg, const MuConfig *opts)
|
||||
(MuMsgPartForeachFunc)save_part_if, &sd);
|
||||
|
||||
if (sd.saved_num == 0) {
|
||||
g_warning ("no %s extracted from this message",
|
||||
opts->save_attachments ? "attachments" : "parts");
|
||||
g_printerr ("no %s extracted from this message",
|
||||
opts->save_attachments ? "attachments" : "parts");
|
||||
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);
|
||||
if (!msg) {
|
||||
if (err) {
|
||||
g_warning ("error: %s", err->message);
|
||||
g_printerr ("error: %s", err->message);
|
||||
g_error_free (err);
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
@ -411,8 +411,8 @@ thread_indent (MuMsgIter *iter)
|
||||
|
||||
ti = mu_msg_iter_get_thread_info (iter);
|
||||
if (!ti) {
|
||||
g_warning ("cannot get thread-info for message %u",
|
||||
mu_msg_iter_get_docid (iter));
|
||||
g_printerr ("cannot get thread-info for message %u\n",
|
||||
mu_msg_iter_get_docid (iter));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -38,13 +38,11 @@ static gboolean MU_CAUGHT_SIGNAL;
|
||||
static void
|
||||
sig_handler (int sig)
|
||||
{
|
||||
if (!MU_CAUGHT_SIGNAL && sig == SIGINT) { /* Ctrl-C */
|
||||
g_print ("\n");
|
||||
g_warning ("shutting down gracefully, "
|
||||
if (!MU_CAUGHT_SIGNAL && sig == SIGINT) /* Ctrl-C */
|
||||
g_print ("\nshutting down gracefully, "
|
||||
"press again to kill immediately");
|
||||
}
|
||||
|
||||
MU_CAUGHT_SIGNAL = TRUE;
|
||||
MU_CAUGHT_SIGNAL = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@ -75,13 +75,11 @@ install_sig_handler (void)
|
||||
sigs[i], g_strerror (errno));;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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
|
||||
* utf8 */
|
||||
|
||||
|
||||
#define COOKIE_PRE '\376'
|
||||
#define COOKIE_POST '\377'
|
||||
|
||||
|
||||
12
mu/mu-cmd.cc
12
mu/mu-cmd.cc
@ -302,13 +302,13 @@ static gboolean
|
||||
check_file_okay (const char *path, gboolean cmd_add)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
if (cmd_add && access(path, R_OK) != 0) {
|
||||
g_warning ("path is not readable: %s: %s",
|
||||
path, strerror (errno));
|
||||
g_printerr ("path is not readable: %s: %s\n",
|
||||
path, strerror (errno));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -341,14 +341,14 @@ foreach_msg_file (Mu::Store& store, const MuConfig *opts,
|
||||
|
||||
if (!check_file_okay (path, TRUE)) {
|
||||
all_ok = FALSE;
|
||||
g_warning ("not a valid message file: %s", path);
|
||||
g_printerr ("not a valid message file: %s\n", path);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!foreach_func (store, path, err)) {
|
||||
all_ok = FALSE;
|
||||
g_warning ("error with %s: %s", path,
|
||||
(err&&*err) ? (*err)->message :
|
||||
g_printerr ("error with %s: %s\n", path,
|
||||
(err&&*err) ? (*err)->message :
|
||||
"something went wrong");
|
||||
g_clear_error (err);
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user