core: timestamp debug statements

This commit is contained in:
Dan Williams
2010-04-29 18:59:11 -07:00
parent fbfb7f8953
commit a13becc225
4 changed files with 42 additions and 6 deletions
+7 -1
View File
@@ -273,6 +273,7 @@ debug_log (MMSerialPort *port, const char *prefix, const char *buf, gsize len)
{
static GString *debug = NULL;
const char *s;
GTimeVal tv;
if (!debug)
debug = g_string_sized_new (256);
@@ -295,7 +296,12 @@ debug_log (MMSerialPort *port, const char *prefix, const char *buf, gsize len)
}
g_string_append_c (debug, '\'');
g_debug ("(%s): %s", mm_port_get_device (MM_PORT (port)), debug->str);
g_get_current_time (&tv);
g_debug ("<%ld.%ld> (%s): %s",
tv.tv_sec,
tv.tv_usec,
mm_port_get_device (MM_PORT (port)),
debug->str);
g_string_truncate (debug, 0);
}
+17 -4
View File
@@ -18,6 +18,7 @@
#include <string.h>
#include <dbus/dbus-glib.h>
#include "mm-modem.h"
#include "mm-options.h"
#include "mm-errors.h"
#include "mm-callback-info.h"
#include "mm-marshal.h"
@@ -643,10 +644,22 @@ mm_modem_set_state (MMModem *self,
dbus_path = (const char *) g_object_get_data (G_OBJECT (self), DBUS_PATH_TAG);
if (dbus_path) {
g_message ("Modem %s: state changed (%s -> %s)",
dbus_path,
state_to_string (old_state),
state_to_string (new_state));
if (mm_options_debug ()) {
GTimeVal tv;
g_get_current_time (&tv);
g_debug ("<%ld.%ld> Modem %s: state changed (%s -> %s)",
tv.tv_sec,
tv.tv_usec,
dbus_path,
state_to_string (old_state),
state_to_string (new_state));
} else {
g_message ("Modem %s: state changed (%s -> %s)",
dbus_path,
state_to_string (old_state),
state_to_string (new_state));
}
}
}
}
+11
View File
@@ -19,6 +19,7 @@
#include <string.h>
#include "mm-port.h"
#include "mm-options.h"
G_DEFINE_TYPE (MMPort, mm_port, G_TYPE_OBJECT)
@@ -140,6 +141,16 @@ mm_port_set_connected (MMPort *self, gboolean connected)
if (priv->connected != connected) {
priv->connected = connected;
g_object_notify (G_OBJECT (self), MM_PORT_CONNECTED);
if (mm_options_debug()) {
GTimeVal tv;
g_get_current_time (&tv);
g_debug ("<%ld.%ld> (%s): port now %s",
tv.tv_sec,
tv.tv_usec,
priv->device,
connected ? "connected" : "disconnected");
}
}
}
+7 -1
View File
@@ -157,6 +157,7 @@ debug_log (MMSerialPort *port, const char *prefix, const char *buf, gsize len)
{
static GString *debug = NULL;
const char *s = buf;
GTimeVal tv;
if (!debug)
debug = g_string_sized_new (512);
@@ -166,7 +167,12 @@ debug_log (MMSerialPort *port, const char *prefix, const char *buf, gsize len)
while (len--)
g_string_append_printf (debug, " %02x", (guint8) (*s++ & 0xFF));
g_debug ("(%s): %s", mm_port_get_device (MM_PORT (port)), debug->str);
g_get_current_time (&tv);
g_debug ("<%ld.%ld> (%s): %s",
tv.tv_sec,
tv.tv_usec,
mm_port_get_device (MM_PORT (port)),
debug->str);
g_string_truncate (debug, 0);
}