serial-parsers: port to use object logging

This commit is contained in:
Aleksander Morgado
2020-03-31 17:09:53 +02:00
parent 72efb1b28d
commit 2e0d23ce72
4 changed files with 13 additions and 10 deletions

View File

@@ -148,7 +148,7 @@ parse_response (MMPortSerial *port,
/* Parse it; returns FALSE if there is nothing we can do with this
* response yet. */
if (!self->priv->response_parser_fn (self->priv->response_parser_user_data, string, &inner_error)) {
if (!self->priv->response_parser_fn (self->priv->response_parser_user_data, string, self, &inner_error)) {
/* Copy what we got back in the response buffer. */
g_byte_array_append (response, (const guint8 *) string->str, string->len);
g_string_free (string, TRUE);

View File

@@ -53,9 +53,10 @@ typedef enum { /*< underscore_name=mm_port_serial_at_flag >*/
MM_PORT_SERIAL_AT_FLAG_GPS_CONTROL = 1 << 3,
} MMPortSerialAtFlag;
typedef gboolean (*MMPortSerialAtResponseParserFn) (gpointer user_data,
GString *response,
GError **error);
typedef gboolean (*MMPortSerialAtResponseParserFn) (gpointer user_data,
GString *response,
gpointer log_object,
GError **error);
typedef void (*MMPortSerialAtUnsolicitedMsgFn) (MMPortSerialAt *port,
GMatchInfo *match_info,

View File

@@ -19,7 +19,7 @@
#include "mm-error-helpers.h"
#include "mm-serial-parsers.h"
#include "mm-log.h"
#include "mm-log-object.h"
/* Clean up the response by removing control characters like <CR><LF> etc */
static void
@@ -161,9 +161,10 @@ mm_serial_parser_v1_add_filter (gpointer data,
}
gboolean
mm_serial_parser_v1_parse (gpointer data,
GString *response,
GError **error)
mm_serial_parser_v1_parse (gpointer data,
GString *response,
gpointer log_object,
GError **error)
{
MMSerialParserV1 *parser = (MMSerialParserV1 *) data;
GMatchInfo *match_info;
@@ -188,7 +189,7 @@ mm_serial_parser_v1_parse (gpointer data,
response,
&local_error)) {
g_assert (local_error != NULL);
mm_dbg ("Got response filtered in serial port: %s", local_error->message);
mm_obj_dbg (log_object, "response filtered in serial port: %s", local_error->message);
g_propagate_error (error, local_error);
response_clean (response);
return TRUE;
@@ -361,7 +362,7 @@ done:
response_clean (response);
if (local_error) {
mm_dbg ("Got failure code %d: %s", local_error->code, local_error->message);
mm_obj_dbg (log_object, "operation failure: %d (%s)", local_error->code, local_error->message);
g_propagate_error (error, local_error);
}

View File

@@ -24,6 +24,7 @@ void mm_serial_parser_v1_set_custom_regex (gpointer data,
GRegex *error);
gboolean mm_serial_parser_v1_parse (gpointer parser,
GString *response,
gpointer log_object,
GError **error);
void mm_serial_parser_v1_destroy (gpointer parser);
gboolean mm_serial_parser_v1_is_known_error (const GError *error);