X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=log.c;h=46fa9e5fc5519da2e276d1294930ca2e96bb5c04;hp=81e9251ba06a9d4d8a74cfe6130b4e13efc2c454;hb=0169f19c53e195df2f96c4df731ad3214c59e20a;hpb=0082d592076fdc3fe06a760d432a48163ee0bd97 diff --git a/log.c b/log.c index 81e9251..46fa9e5 100644 --- a/log.c +++ b/log.c @@ -1,5 +1,5 @@ /* - * This file is part of the sigrok project. + * This file is part of the libsigrokdecode project. * * Copyright (C) 2011-2012 Uwe Hermann * @@ -18,11 +18,25 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "sigrokdecode.h" /* First, so we avoid a _POSIX_C_SOURCE warning. */ -#include "sigrokdecode-internal.h" +#include "libsigrokdecode.h" /* First, so we avoid a _POSIX_C_SOURCE warning. */ +#include "libsigrokdecode-internal.h" #include #include +/** + * @file + * + * Controlling the libsigrokdecode message logging functionality. + */ + +/** + * @defgroup grp_logging Logging + * + * Controlling the libsigrokdecode message logging functionality. + * + * @{ + */ + /* Currently selected libsigrokdecode loglevel. Default: SRD_LOG_WARN. */ static int srd_loglevel = SRD_LOG_WARN; /* Show errors+warnings per default. */ @@ -40,8 +54,10 @@ static srd_log_callback_t srd_log_callback = srd_logv; static void *srd_log_callback_data = NULL; /* Log domain (a short string that is used as prefix for all messages). */ +/** @cond PRIVATE */ #define LOGDOMAIN_MAXLEN 30 #define LOGDOMAIN_DEFAULT "srd: " +/** @endcond */ static char srd_log_domain[LOGDOMAIN_MAXLEN + 1] = LOGDOMAIN_DEFAULT; /** @@ -59,6 +75,8 @@ static char srd_log_domain[LOGDOMAIN_MAXLEN + 1] = LOGDOMAIN_DEFAULT; * SRD_LOG_WARN, SRD_LOG_INFO, SRD_LOG_DBG, or SRD_LOG_SPEW). * * @return SRD_OK upon success, SRD_ERR_ARG upon invalid loglevel. + * + * @since 0.1.0 */ SRD_API int srd_log_loglevel_set(int loglevel) { @@ -78,6 +96,8 @@ SRD_API int srd_log_loglevel_set(int loglevel) * Get the libsigrokdecode loglevel. * * @return The currently configured libsigrokdecode loglevel. + * + * @since 0.1.0 */ SRD_API int srd_log_loglevel_get(void) { @@ -97,6 +117,8 @@ SRD_API int srd_log_loglevel_get(void) * the caller does not need to keep it around. * * @return SRD_OK upon success, SRD_ERR_ARG upon invalid logdomain. + * + * @since 0.1.0 */ SRD_API int srd_log_logdomain_set(const char *logdomain) { @@ -105,7 +127,6 @@ SRD_API int srd_log_logdomain_set(const char *logdomain) return SRD_ERR_ARG; } - /* TODO: Error handling. */ snprintf((char *)&srd_log_domain, LOGDOMAIN_MAXLEN, "%s", logdomain); srd_dbg("Log domain set to '%s'.", (const char *)&srd_log_domain); @@ -119,6 +140,8 @@ SRD_API int srd_log_logdomain_set(const char *logdomain) * @return A copy of the currently configured libsigrokdecode logdomain * string. The caller is responsible for g_free()ing the string when * it is no longer needed. + * + * @since 0.1.0 */ SRD_API char *srd_log_logdomain_get(void) { @@ -138,6 +161,8 @@ SRD_API char *srd_log_logdomain_get(void) * pass any data. * * @return SRD_OK upon success, SRD_ERR_ARG upon invalid arguments. + * + * @since 0.1.0 */ SRD_API int srd_log_callback_set(srd_log_callback_t cb, void *cb_data) { @@ -160,6 +185,8 @@ SRD_API int srd_log_callback_set(srd_log_callback_t cb, void *cb_data) * Additionally, the internal 'srd_log_callback_data' pointer is set to NULL. * * @return SRD_OK upon success, a (negative) error code otherwise. + * + * @since 0.1.0 */ SRD_API int srd_log_callback_set_default(void) { @@ -183,7 +210,7 @@ static int srd_logv(void *cb_data, int loglevel, const char *format, /* Only output messages of at least the selected loglevel(s). */ if (loglevel > srd_loglevel) - return SRD_OK; /* TODO? */ + return SRD_OK; if (srd_log_domain[0] != '\0') fprintf(stderr, "%s", srd_log_domain); @@ -193,6 +220,7 @@ static int srd_logv(void *cb_data, int loglevel, const char *format, return ret; } +/** @private */ SRD_PRIV int srd_log(int loglevel, const char *format, ...) { int ret; @@ -205,6 +233,7 @@ SRD_PRIV int srd_log(int loglevel, const char *format, ...) return ret; } +/** @private */ SRD_PRIV int srd_spew(const char *format, ...) { int ret; @@ -218,6 +247,7 @@ SRD_PRIV int srd_spew(const char *format, ...) return ret; } +/** @private */ SRD_PRIV int srd_dbg(const char *format, ...) { int ret; @@ -231,6 +261,7 @@ SRD_PRIV int srd_dbg(const char *format, ...) return ret; } +/** @private */ SRD_PRIV int srd_info(const char *format, ...) { int ret; @@ -244,6 +275,7 @@ SRD_PRIV int srd_info(const char *format, ...) return ret; } +/** @private */ SRD_PRIV int srd_warn(const char *format, ...) { int ret; @@ -257,6 +289,7 @@ SRD_PRIV int srd_warn(const char *format, ...) return ret; } +/** @private */ SRD_PRIV int srd_err(const char *format, ...) { int ret; @@ -269,3 +302,5 @@ SRD_PRIV int srd_err(const char *format, ...) return ret; } + +/** @} */