From: Uwe Hermann Date: Thu, 26 Jan 2012 00:15:10 +0000 (+0100) Subject: srd: Remove manual log domain ("srd: ") prefixes. X-Git-Tag: libsigrokdecode-0.1.0~94 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=7a1712c4fd07f64222079acd5ec3fa3348a5cb15;p=libsigrokdecode.git srd: Remove manual log domain ("srd: ") prefixes. --- diff --git a/controller.c b/controller.c index 0cad3f5..e325e0a 100644 --- a/controller.c +++ b/controller.c @@ -68,7 +68,7 @@ int srd_init(void) { int ret; - srd_dbg("srd: initializing"); + srd_dbg("Initializing libsigrokdecode."); /* Add our own module to the list of built-in modules. */ PyImport_AppendInittab("sigrokdecode", PyInit_sigrokdecode); @@ -105,7 +105,7 @@ int srd_init(void) int srd_exit(void) { - srd_dbg("srd: exiting"); + srd_dbg("Exiting libsigrokdecode."); srd_unload_all_decoders(); g_slist_free(pd_list); @@ -275,7 +275,7 @@ err_out: if (key) g_free(key); if (PyErr_Occurred()) - catch_exception("srd: stray exception in srd_instance_set_options()"); + catch_exception("Stray exception in srd_instance_set_options()."); return ret; } @@ -371,7 +371,7 @@ struct srd_decoder_instance *srd_instance_new(const char *decoder_id, int i; char *instance_id; - srd_dbg("srd: creating new %s instance", decoder_id); + srd_dbg("Creating new %s instance.", decoder_id); if (!(dec = srd_get_decoder_by_id(decoder_id))) { srd_err("Protocol decoder %s not found.", decoder_id); @@ -506,8 +506,8 @@ int srd_instance_start(struct srd_decoder_instance *di, PyObject *args) GSList *l; struct srd_decoder_instance *next_di; - srd_dbg("srd: calling start() method on protocol decoder instance %s", - di->instance_id); + srd_dbg("Calling start() method on protocol decoder instance %s.", + di->instance_id); if (!(py_name = PyUnicode_FromString("start"))) { srd_err("Unable to build python object for 'start'."); @@ -540,34 +540,34 @@ int srd_instance_start(struct srd_decoder_instance *di, PyObject *args) * Run the specified decoder function. * * @param start_samplenum The starting sample number for the buffer's sample - * set, relative to the start of capture. - * @param di The decoder instance to call. - * @param inbuf The buffer to decode. - * @param inbuflen Length of the buffer. + * set, relative to the start of capture. + * @param di The decoder instance to call. Must not be NULL. + * @param inbuf The buffer to decode. Must not be NULL. + * @param inbuflen Length of the buffer. Must be > 0. * * @return SRD_OK upon success, a (negative) error code otherwise. */ int srd_instance_decode(uint64_t start_samplenum, - struct srd_decoder_instance *di, uint8_t *inbuf, uint64_t inbuflen) + struct srd_decoder_instance *di, uint8_t *inbuf, uint64_t inbuflen) { PyObject *py_res; srd_logic *logic; uint64_t end_samplenum; - srd_dbg("srd: calling decode() on instance %s with %d bytes starting " - "at sample %d", di->instance_id, inbuflen, start_samplenum); + srd_dbg("Calling decode() on instance %s with %d bytes starting " + "at sample %d.", di->instance_id, inbuflen, start_samplenum); /* Return an error upon unusable input. */ - if (di == NULL) { - srd_dbg("srd: empty decoder instance"); + if (!di) { + srd_dbg("empty decoder instance"); return SRD_ERR_ARG; } - if (inbuf == NULL) { - srd_dbg("srd: NULL buffer pointer"); + if (!inbuf) { + srd_dbg("NULL buffer pointer"); return SRD_ERR_ARG; } if (inbuflen == 0) { - srd_dbg("srd: empty buffer"); + srd_dbg("empty buffer"); return SRD_ERR_ARG; } @@ -604,8 +604,8 @@ int srd_session_start(int num_probes, int unitsize, uint64_t samplerate) struct srd_decoder_instance *di; int ret; - srd_dbg("srd: calling start() on all instances with %d probes, " - "unitsize %d samplerate %d", num_probes, unitsize, samplerate); + srd_dbg("Calling start() on all instances with %d probes, " + "unitsize %d samplerate %d.", num_probes, unitsize, samplerate); /* Currently only one item of metadata is passed along to decoders, * samplerate. This can be extended as needed. @@ -636,9 +636,9 @@ int srd_session_feed(uint64_t start_samplenum, uint8_t *inbuf, uint64_t inbuflen GSList *d; int ret; - srd_dbg("srd: calling decode() on all instances with starting sample " - "number %"PRIu64", %"PRIu64" bytes at 0x%p", start_samplenum, - inbuflen, inbuf); + srd_dbg("Calling decode() on all instances with starting sample " + "number %"PRIu64", %"PRIu64" bytes at 0x%p", start_samplenum, + inbuflen, inbuf); for (d = di_list; d; d = d->next) { if ((ret = srd_instance_decode(start_samplenum, d->data, inbuf, @@ -654,7 +654,7 @@ int srd_register_callback(int output_type, void *cb) { struct srd_pd_callback *pd_cb; - srd_dbg("srd: registering new callback for output type %d", output_type); + srd_dbg("Registering new callback for output type %d.", output_type); if (!(pd_cb = g_try_malloc(sizeof(struct srd_pd_callback)))) return SRD_ERR_MALLOC; @@ -686,13 +686,12 @@ void *srd_find_callback(int output_type) /* This is the backend function to python sigrokdecode.add() call. */ -int pd_add(struct srd_decoder_instance *di, int output_type, - char *proto_id) +int pd_add(struct srd_decoder_instance *di, int output_type, char *proto_id) { struct srd_pd_output *pdo; - srd_dbg("srd: instance %s creating new output type %d for %s", - di->instance_id, output_type, proto_id); + srd_dbg("Instance %s creating new output type %d for %s.", + di->instance_id, output_type, proto_id); if (!(pdo = g_try_malloc(sizeof(struct srd_pd_output)))) return -1; diff --git a/decoder.c b/decoder.c index f242ffe..593f259 100644 --- a/decoder.c +++ b/decoder.c @@ -137,12 +137,12 @@ int srd_load_decoder(const char *name, struct srd_decoder **dec) int alen, ret, i; char **ann; - srd_dbg("srd: loading module '%s'", name); + srd_dbg("Loading module '%s'.", name); py_basedec = py_method = py_attr = NULL; if (!(d = g_try_malloc0(sizeof(struct srd_decoder)))) { - srd_dbg("srd: Failed to malloc struct srd_decoder"); + srd_dbg("Failed to malloc struct srd_decoder."); ret = SRD_ERR_MALLOC; goto err_out; } @@ -164,7 +164,7 @@ int srd_load_decoder(const char *name, struct srd_decoder **dec) } if (!(py_basedec = PyObject_GetAttrString(mod_sigrokdecode, "Decoder"))) { - srd_dbg("srd: sigrokdecode module not loaded"); + srd_dbg("sigrokdecode module not loaded."); goto err_out; } diff --git a/exception.c b/exception.c index 07ffab3..aa7ab61 100644 --- a/exception.c +++ b/exception.c @@ -41,8 +41,8 @@ void catch_exception(const char *format, ...) PyErr_NormalizeException(&etype, &evalue, &etb); if (!(py_str = PyObject_Str(evalue))) { - /* Shouldn't happen */ - srd_dbg("srd: failed to convert exception value to string"); + /* Shouldn't happen. */ + srd_dbg("Failed to convert exception value to string."); return; } @@ -74,8 +74,7 @@ void catch_exception(const char *format, ...) py_tb->tb_frame->f_code->co_name); py_str_as_str(py_str, &tracestr); Py_DecRef(py_str); - g_string_printf(msg, "srd: %s in %s: %s", ename, - tracestr, str); + g_string_printf(msg, "%s in %s: %s", ename, tracestr, str); srd_dbg(msg->str); g_free(tracestr); } diff --git a/log.c b/log.c index c7fe76f..c89a74b 100644 --- a/log.c +++ b/log.c @@ -63,7 +63,7 @@ int srd_set_loglevel(int loglevel) srd_loglevel = loglevel; - srd_dbg("srd: loglevel set to %d", loglevel); + srd_dbg("libsigrokdecode loglevel set to %d.", loglevel); return SRD_OK; } diff --git a/type_decoder.c b/type_decoder.c index 6e34dff..6ed2787 100644 --- a/type_decoder.c +++ b/type_decoder.c @@ -97,7 +97,7 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) if (!(di = srd_instance_find_by_obj(NULL, self))) { /* Shouldn't happen. */ - srd_dbg("srd: put(): self instance not found."); + srd_dbg("put(): self instance not found."); return NULL; } @@ -114,8 +114,9 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) } pdo = l->data; - srd_spew("srd: instance %s put %d-%d %s on oid %d", di->instance_id, - start_sample, end_sample, OUTPUT_TYPES[pdo->output_type], output_id); + srd_spew("Instance %s put %d-%d %s on oid %d.", di->instance_id, + start_sample, end_sample, OUTPUT_TYPES[pdo->output_type], + output_id); if (!(pdata = g_try_malloc0(sizeof(struct srd_proto_data)))) return NULL; @@ -141,8 +142,8 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) next_di = l->data; /* TODO: is this needed? */ Py_XINCREF(next_di->py_instance); - srd_spew("srd: sending %d-%d to instance %s", - start_sample, end_sample, next_di->instance_id); + srd_spew("Sending %d-%d to instance %s", + start_sample, end_sample, next_di->instance_id); if (!(py_res = PyObject_CallMethod(next_di->py_instance, "decode", "KKO", start_sample, end_sample, data))) { catch_exception("calling %s decode(): ", next_di->instance_id); diff --git a/util.c b/util.c index 090c0c1..680d3b1 100644 --- a/util.c +++ b/util.c @@ -40,8 +40,8 @@ int py_attr_as_str(PyObject *py_obj, const char *attr, char **outstr) int ret; if (!PyObject_HasAttrString(py_obj, attr)) { - srd_dbg("srd: %s object has no attribute '%s'.", - Py_TYPE(py_obj)->tp_name, attr); + srd_dbg("%s object has no attribute '%s'.", + Py_TYPE(py_obj)->tp_name, attr); return SRD_ERR_PYTHON; } @@ -51,8 +51,8 @@ int py_attr_as_str(PyObject *py_obj, const char *attr, char **outstr) } if (!PyUnicode_Check(py_str)) { - srd_dbg("srd: %s attribute should be a string, but is a %s.", - attr, Py_TYPE(py_str)->tp_name); + srd_dbg("%s attribute should be a string, but is a %s.", + attr, Py_TYPE(py_str)->tp_name); Py_DecRef(py_str); return SRD_ERR_PYTHON; } @@ -81,18 +81,18 @@ int py_dictitem_as_str(PyObject *py_obj, const char *key, char **outstr) int ret; if (!PyDict_Check(py_obj)) { - srd_dbg("srd: Object is a %s, not a dictionary.", Py_TYPE(py_obj)->tp_name); + srd_dbg("Object is a %s, not a dictionary.", Py_TYPE(py_obj)->tp_name); return SRD_ERR_PYTHON; } if (!(py_value = PyDict_GetItemString(py_obj, key))) { - srd_dbg("srd: Dictionary has no attribute '%s'.", key); + srd_dbg("Dictionary has no attribute '%s'.", key); return SRD_ERR_PYTHON; } if (!PyUnicode_Check(py_value)) { - srd_dbg("srd: Dictionary value for %s should be a string, but is a %s.", - key, Py_TYPE(py_value)->tp_name); + srd_dbg("Dictionary value for %s should be a string, but is a %s.", + key, Py_TYPE(py_value)->tp_name); return SRD_ERR_PYTHON; } @@ -123,7 +123,7 @@ int py_str_as_str(PyObject *py_str, char **outstr) ret = SRD_OK; if (!PyUnicode_Check(py_str)) { - srd_dbg("srd: object is a %s, not a string object", Py_TYPE(py_str)->tp_name); + srd_dbg("Object is a %s, not a string object.", Py_TYPE(py_str)->tp_name); ret = SRD_ERR_PYTHON; goto err_out; } @@ -138,7 +138,7 @@ int py_str_as_str(PyObject *py_str, char **outstr) } if (!(*outstr = g_strdup(str))) { - srd_dbg("srd: malloc failed"); + srd_dbg("outstr malloc failed"); ret = SRD_ERR_MALLOC; goto err_out; }