core: Prettify _gpgme_io_select debug output again and fix TRACE_SYSRES.
* src/debug.c (_gpgme_debug): Take better care of NULL userinfo.
(_gpgme_debug_end): Rework.
(_trace_sysres): Print ERRNO and not the supplied RES.
--
The TRACE_SYSRES patch fixes
Regression-due-to: 7a1e7006d0
Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
3a3648e3a5
commit
0f68c9f16b
21
src/debug.c
21
src/debug.c
@ -254,6 +254,7 @@ _gpgme_debug (void **line, int level, int mode,
|
|||||||
int indent;
|
int indent;
|
||||||
char *prefix, *stdinfo, *userinfo;
|
char *prefix, *stdinfo, *userinfo;
|
||||||
const char *modestr;
|
const char *modestr;
|
||||||
|
int no_userinfo = 0;
|
||||||
|
|
||||||
if (debug_level < level)
|
if (debug_level < level)
|
||||||
return 0;
|
return 0;
|
||||||
@ -295,7 +296,13 @@ _gpgme_debug (void **line, int level, int mode,
|
|||||||
else
|
else
|
||||||
stdinfo = gpgrt_bsprintf ("%s: %s: ", func, modestr);
|
stdinfo = gpgrt_bsprintf ("%s: %s: ", func, modestr);
|
||||||
|
|
||||||
userinfo = gpgrt_vbsprintf (format, arg_ptr);
|
if (format && *format)
|
||||||
|
userinfo = gpgrt_vbsprintf (format, arg_ptr);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
userinfo = NULL;
|
||||||
|
no_userinfo = 1;
|
||||||
|
}
|
||||||
va_end (arg_ptr);
|
va_end (arg_ptr);
|
||||||
|
|
||||||
if (mode != -1 && (!format || !*format))
|
if (mode != -1 && (!format || !*format))
|
||||||
@ -317,7 +324,7 @@ _gpgme_debug (void **line, int level, int mode,
|
|||||||
prefix? prefix : "GPGME out-of-core ",
|
prefix? prefix : "GPGME out-of-core ",
|
||||||
!modestr? "" : stdinfo? stdinfo :
|
!modestr? "" : stdinfo? stdinfo :
|
||||||
(!format || !*format)? "" :"out-of-core ",
|
(!format || !*format)? "" :"out-of-core ",
|
||||||
userinfo? userinfo : "out-of-core",
|
userinfo? userinfo : no_userinfo? "" : "out-of-core",
|
||||||
need_lf? "\n":"");
|
need_lf? "\n":"");
|
||||||
fflush (errfp);
|
fflush (errfp);
|
||||||
}
|
}
|
||||||
@ -365,12 +372,16 @@ _gpgme_debug_add (void **line, const char *format, ...)
|
|||||||
void
|
void
|
||||||
_gpgme_debug_end (void **line)
|
_gpgme_debug_end (void **line)
|
||||||
{
|
{
|
||||||
|
const char *string;
|
||||||
|
|
||||||
if (!*line)
|
if (!*line)
|
||||||
return;
|
return;
|
||||||
|
string = *line;
|
||||||
|
|
||||||
/* The smallest possible level is 1, so force logging here by
|
fprintf (errfp, "%s%s",
|
||||||
using that. */
|
string,
|
||||||
_gpgme_debug (NULL, 1, -1, NULL, NULL, NULL, "%s", (char*)*line);
|
(*string && string[strlen (string)-1] != '\n')? "\n":"");
|
||||||
|
fflush (errfp);
|
||||||
gpgrt_free (*line);
|
gpgrt_free (*line);
|
||||||
*line = NULL;
|
*line = NULL;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#ifdef HAVE_STDINT_H
|
#ifdef HAVE_STDINT_H
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "gpgme.h" /* Required for gpgme_error stuff. */
|
#include "gpgme.h" /* Required for gpgme_error stuff. */
|
||||||
|
|
||||||
@ -151,7 +152,7 @@ _trace_sysres (int res, int lvl, const char *func, int line)
|
|||||||
else
|
else
|
||||||
_gpgme_debug (NULL, lvl, -1, NULL, NULL, NULL,
|
_gpgme_debug (NULL, lvl, -1, NULL, NULL, NULL,
|
||||||
"%s:%d: error: %s (%d)\n",
|
"%s:%d: error: %s (%d)\n",
|
||||||
func, line, strerror (res), res);
|
func, line, strerror (errno), errno);
|
||||||
_gpgme_debug_frame_end ();
|
_gpgme_debug_frame_end ();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user