From: Daniel Elstner Date: Sun, 13 Sep 2015 09:58:44 +0000 (+0200) Subject: log: Remove sr_log_logdomain_{get,set} from the API X-Git-Tag: libsigrok-0.4.0~307 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=782b16447b25ce31d41764ae91681a6aa4f3fe0d;p=libsigrok.git log: Remove sr_log_logdomain_{get,set} from the API The confusingly named sr_log_logdomain_set() simply set a global string prefixed to the log message by the default log callback. This is pretty much useless, misleadingly named, and not used by either sigrok-cli or PulseView. --- diff --git a/bindings/cxx/classes.cpp b/bindings/cxx/classes.cpp index 6c3b15f1..b7a3d84d 100644 --- a/bindings/cxx/classes.cpp +++ b/bindings/cxx/classes.cpp @@ -161,16 +161,6 @@ void Context::set_log_level(const LogLevel *level) check(sr_log_loglevel_set(level->id())); } -string Context::log_domain() -{ - return valid_string(sr_log_logdomain_get()); -} - -void Context::set_log_domain(string value) -{ - check(sr_log_logdomain_set(value.c_str())); -} - static int call_log_callback(void *cb_data, int loglevel, const char *format, va_list args) { va_list args_copy; diff --git a/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp b/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp index b9395a71..02316113 100644 --- a/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp +++ b/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp @@ -253,11 +253,6 @@ public: /** Set the log level. * @param level LogLevel to use. */ void set_log_level(const LogLevel *level); - /** Current log domain. */ - string log_domain(); - /** Set the log domain. - * @param value Log domain prefix string. */ - void set_log_domain(string value); /** Set the log callback. * @param callback Callback of the form callback(LogLevel, string). */ void set_log_callback(LogCallbackFunction callback); diff --git a/bindings/swig/classes.i b/bindings/swig/classes.i index b6ddbbca..8f57e418 100644 --- a/bindings/swig/classes.i +++ b/bindings/swig/classes.i @@ -176,9 +176,6 @@ typedef std::map %attribute(sigrok::Context, const sigrok::LogLevel *, log_level, log_level, set_log_level); -%attributestring(sigrok::Context, - std::string, log_domain, log_domain, set_log_domain); - %attributestring(sigrok::Driver, std::string, name, name); %attributestring(sigrok::Driver, std::string, long_name, long_name); diff --git a/include/libsigrok/proto.h b/include/libsigrok/proto.h index 7396c57b..19c1680f 100644 --- a/include/libsigrok/proto.h +++ b/include/libsigrok/proto.h @@ -49,8 +49,6 @@ SR_API int sr_log_loglevel_set(int loglevel); SR_API int sr_log_loglevel_get(void); SR_API int sr_log_callback_set(sr_log_callback cb, void *cb_data); SR_API int sr_log_callback_set_default(void); -SR_API int sr_log_logdomain_set(const char *logdomain); -SR_API char *sr_log_logdomain_get(void); /*--- device.c --------------------------------------------------------------*/ diff --git a/src/log.c b/src/log.c index e12c8f4c..2265181e 100644 --- a/src/log.c +++ b/src/log.c @@ -55,13 +55,6 @@ static sr_log_callback sr_log_cb = sr_logv; */ static void *sr_log_cb_data = NULL; -/* Log domain (a short string that is used as prefix for all messages). */ -/** @cond PRIVATE */ -#define LOGDOMAIN_MAXLEN 30 -#define LOGDOMAIN_DEFAULT "sr: " -/** @endcond */ -static char sr_log_domain[LOGDOMAIN_MAXLEN + 1] = LOGDOMAIN_DEFAULT; - /** @cond PRIVATE */ #define LOGLEVEL_TIMESTAMP SR_LOG_DBG /** @endcond */ @@ -113,54 +106,6 @@ SR_API int sr_log_loglevel_get(void) return cur_loglevel; } -/** - * Set the libsigrok logdomain string. - * - * @param logdomain The string to use as logdomain for libsigrok log - * messages from now on. Must not be NULL. The maximum - * length of the string is 30 characters (this does not - * include the trailing NUL-byte). Longer strings are - * truncated. - * In order to not use a logdomain, pass an empty string. - * The function makes its own copy of the input string, i.e. - * the caller does not need to keep it around. - * - * @retval SR_OK upon success. - * @retval SR_ERR_ARG @a logdomain was NULL. - * @retval SR_ERR @a logdomain was truncated. - * - * @since 0.1.0 - */ -SR_API int sr_log_logdomain_set(const char *logdomain) -{ - size_t len; - - if (!logdomain) { - sr_err("%s: logdomain was NULL", __func__); - return SR_ERR_ARG; - } - - len = g_strlcpy(sr_log_domain, logdomain, sizeof sr_log_domain); - - sr_dbg("Log domain set to '%s'.", sr_log_domain); - - return (len < sizeof sr_log_domain) ? SR_OK : SR_ERR; -} - -/** - * Get the currently configured libsigrok logdomain. - * - * @return A copy of the currently configured libsigrok logdomain - * string. The caller is responsible for g_free()ing the string when - * it is no longer needed. - * - * @since 0.1.0 - */ -SR_API char *sr_log_logdomain_get(void) -{ - return g_strdup(sr_log_domain); -} - /** * Set the libsigrok log callback to the specified function. * @@ -236,8 +181,6 @@ static int sr_logv(void *cb_data, int loglevel, const char *format, va_list args minutes, seconds, microseconds) < 0) return SR_ERR; } - if (sr_log_domain[0] != '\0' && fputs(sr_log_domain, stderr) < 0) - return SR_ERR; if (vfprintf(stderr, format, args) < 0) return SR_ERR; if (putc('\n', stderr) < 0)