forked from ariadne/pkgconf
libpkgconf: overhaul pkgconf_trace() a little
parent
9fc170bda5
commit
d20efff495
|
@ -54,7 +54,8 @@ pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error
|
||||||
|
|
||||||
pkgconf_client_set_error_handler(client, error_handler, error_handler_data);
|
pkgconf_client_set_error_handler(client, error_handler, error_handler_data);
|
||||||
pkgconf_client_set_warn_handler(client, NULL, NULL);
|
pkgconf_client_set_warn_handler(client, NULL, NULL);
|
||||||
pkgconf_client_set_trace_handler(client, NULL, NULL);
|
if (client->trace_handler == NULL)
|
||||||
|
pkgconf_client_set_trace_handler(client, NULL, NULL);
|
||||||
|
|
||||||
pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_LIBRARY_PATH", SYSTEM_LIBDIR, &client->filter_libdirs, false);
|
pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_LIBRARY_PATH", SYSTEM_LIBDIR, &client->filter_libdirs, false);
|
||||||
pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_INCLUDE_PATH", SYSTEM_INCLUDEDIR, &client->filter_includedirs, false);
|
pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_INCLUDE_PATH", SYSTEM_INCLUDEDIR, &client->filter_includedirs, false);
|
||||||
|
@ -273,25 +274,33 @@ pkgconf_warn(const pkgconf_client_t *client, const char *format, ...)
|
||||||
/*
|
/*
|
||||||
* !doc
|
* !doc
|
||||||
*
|
*
|
||||||
* .. c:function:: bool pkgconf_trace(const pkgconf_client_t *client, const char *format, ...)
|
* .. c:function:: bool pkgconf_trace(const pkgconf_client_t *client, const char *filename, size_t len, const char *funcname, const char *format, ...)
|
||||||
*
|
*
|
||||||
* Report a message to a client-registered trace handler.
|
* Report a message to a client-registered trace handler.
|
||||||
*
|
*
|
||||||
* :param pkgconf_client_t* client: The pkgconf client object to report the trace message to.
|
* :param pkgconf_client_t* client: The pkgconf client object to report the trace message to.
|
||||||
|
* :param char* filename: The file the function is in.
|
||||||
|
* :param size_t lineno: The line number currently being executed.
|
||||||
|
* :param char* funcname: The function name to use.
|
||||||
* :param char* format: A printf-style format string to use for formatting the trace message.
|
* :param char* format: A printf-style format string to use for formatting the trace message.
|
||||||
* :return: true if the trace handler processed the message, else false.
|
* :return: true if the trace handler processed the message, else false.
|
||||||
* :rtype: bool
|
* :rtype: bool
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
pkgconf_trace(const pkgconf_client_t *client, const char *format, ...)
|
pkgconf_trace(const pkgconf_client_t *client, const char *filename, size_t lineno, const char *funcname, const char *format, ...)
|
||||||
{
|
{
|
||||||
char errbuf[PKGCONF_BUFSIZE];
|
char errbuf[PKGCONF_BUFSIZE];
|
||||||
|
size_t len;
|
||||||
va_list va;
|
va_list va;
|
||||||
|
|
||||||
|
len = snprintf(errbuf, sizeof errbuf, "%s:%zu [%s]: ", filename, lineno, funcname);
|
||||||
|
|
||||||
va_start(va, format);
|
va_start(va, format);
|
||||||
vsnprintf(errbuf, sizeof errbuf, format, va);
|
vsnprintf(errbuf + len, sizeof(errbuf) - len, format, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
|
pkgconf_strlcat(errbuf, "\n", sizeof errbuf);
|
||||||
|
|
||||||
return client->trace_handler(errbuf, client, client->trace_handler_data);
|
return client->trace_handler(errbuf, client, client->trace_handler_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -218,9 +218,19 @@ void pkgconf_client_set_trace_handler(pkgconf_client_t *client, pkgconf_error_ha
|
||||||
|
|
||||||
bool pkgconf_error(const pkgconf_client_t *client, const char *format, ...) PRINTFLIKE(2, 3);
|
bool pkgconf_error(const pkgconf_client_t *client, const char *format, ...) PRINTFLIKE(2, 3);
|
||||||
bool pkgconf_warn(const pkgconf_client_t *client, const char *format, ...) PRINTFLIKE(2, 3);
|
bool pkgconf_warn(const pkgconf_client_t *client, const char *format, ...) PRINTFLIKE(2, 3);
|
||||||
bool pkgconf_trace(const pkgconf_client_t *client, const char *format, ...) PRINTFLIKE(2, 3);
|
bool pkgconf_trace(const pkgconf_client_t *client, const char *filename, size_t lineno, const char *funcname, const char *format, ...) PRINTFLIKE(5, 6);
|
||||||
bool pkgconf_default_error_handler(const char *msg, const pkgconf_client_t *client, const void *data);
|
bool pkgconf_default_error_handler(const char *msg, const pkgconf_client_t *client, const void *data);
|
||||||
|
|
||||||
|
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
|
||||||
|
#define PKGCONF_TRACE(client, ...) do { \
|
||||||
|
pkgconf_trace(client, __FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__); \
|
||||||
|
} while (0);
|
||||||
|
#else
|
||||||
|
#define PKGCONF_TRACE(client, ...) do { \
|
||||||
|
pkgconf_trace(client, __FILE__, __LINE__, __func__, __VA_ARGS__); \
|
||||||
|
} while (0);
|
||||||
|
#endif
|
||||||
|
|
||||||
pkgconf_pkg_t *pkgconf_pkg_ref(const pkgconf_client_t *client, pkgconf_pkg_t *pkg);
|
pkgconf_pkg_t *pkgconf_pkg_ref(const pkgconf_client_t *client, pkgconf_pkg_t *pkg);
|
||||||
void pkgconf_pkg_unref(pkgconf_client_t *client, pkgconf_pkg_t *pkg);
|
void pkgconf_pkg_unref(pkgconf_client_t *client, pkgconf_pkg_t *pkg);
|
||||||
void pkgconf_pkg_free(pkgconf_client_t *client, pkgconf_pkg_t *pkg);
|
void pkgconf_pkg_free(pkgconf_client_t *client, pkgconf_pkg_t *pkg);
|
||||||
|
|
Loading…
Reference in New Issue