core: rework logging
Make it more flexible, add logging to a file, and absolute and relative timestamps.
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "mm-callback-info.h"
|
||||
#include "mm-serial-port.h"
|
||||
#include "mm-serial-parsers.h"
|
||||
#include "mm-log.h"
|
||||
|
||||
static void modem_init (MMModem *modem_class);
|
||||
|
||||
@@ -140,7 +141,7 @@ evdo_state_done (MMAtSerialPort *port,
|
||||
G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
if (!r) {
|
||||
/* Parse error; warn about it and assume EVDO is not available */
|
||||
g_warning ("AnyDATA(%s): *HSTATE parse regex creation failed.", __func__);
|
||||
mm_warn ("ANYDATA: *HSTATE parse regex creation failed.");
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -167,7 +168,7 @@ evdo_state_done (MMAtSerialPort *port,
|
||||
reg_state = MM_MODEM_CDMA_REGISTRATION_STATE_REGISTERED;
|
||||
break;
|
||||
default:
|
||||
g_message ("ANYDATA: unknown *STATE (%d); assuming no service.", val);
|
||||
mm_warn ("ANYDATA: unknown *STATE (%d); assuming no service.", val);
|
||||
/* fall through */
|
||||
case 0: /* NO SERVICE */
|
||||
case 1: /* ACQUISITION */
|
||||
@@ -206,7 +207,7 @@ state_done (MMAtSerialPort *port,
|
||||
r = g_regex_new ("\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*([^,\\)]*)\\s*,.*",
|
||||
G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
if (!r) {
|
||||
g_warning ("AnyDATA(%s): *STATE parse regex creation failed.", __func__);
|
||||
mm_warn ("ANYDATA: *STATE parse regex creation failed.");
|
||||
mm_callback_info_schedule (info);
|
||||
return;
|
||||
}
|
||||
@@ -235,7 +236,7 @@ state_done (MMAtSerialPort *port,
|
||||
reg_state = MM_MODEM_CDMA_REGISTRATION_STATE_REGISTERED;
|
||||
break;
|
||||
default:
|
||||
g_warning ("ANYDATA: unknown *STATE (%d); assuming no service.", val);
|
||||
mm_warn ("ANYDATA: unknown *STATE (%d); assuming no service.", val);
|
||||
/* fall through */
|
||||
case 0: /* NO SERVICE */
|
||||
break;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "mm-callback-info.h"
|
||||
#include "mm-serial-port.h"
|
||||
#include "mm-serial-parsers.h"
|
||||
#include "mm-log.h"
|
||||
|
||||
static void modem_init (MMModem *modem_class);
|
||||
|
||||
@@ -79,7 +80,7 @@ parse_quality (const char *str, const char *detail)
|
||||
quality = strtol (str, NULL, 10);
|
||||
if (errno == 0) {
|
||||
quality = CLAMP (quality, 0, 100);
|
||||
g_debug ("%s: %ld", detail, quality);
|
||||
mm_dbg ("%s: %ld", detail, quality);
|
||||
return (gint) quality;
|
||||
}
|
||||
return -1;
|
||||
@@ -177,7 +178,7 @@ sysinfo_done (MMAtSerialPort *port,
|
||||
r = g_regex_new ("\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)",
|
||||
G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
if (!r) {
|
||||
g_warning ("Huawei(%s): ^SYSINFO parse regex creation failed.", __func__);
|
||||
mm_warn ("Huawei: ^SYSINFO parse regex creation failed.");
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -218,7 +219,7 @@ sysinfo_done (MMAtSerialPort *port,
|
||||
mm_generic_cdma_query_reg_state_set_callback_1x_state (info, reg_state);
|
||||
}
|
||||
} else
|
||||
g_warning ("Huawei(%s): failed to parse ^SYSINFO response.", __func__);
|
||||
mm_warn ("Huawei: failed to parse ^SYSINFO response.");
|
||||
|
||||
g_match_info_free (match_info);
|
||||
g_regex_unref (r);
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "mm-callback-info.h"
|
||||
#include "mm-at-serial-port.h"
|
||||
#include "mm-serial-parsers.h"
|
||||
#include "mm-options.h"
|
||||
#include "mm-log.h"
|
||||
|
||||
static void modem_init (MMModem *modem_class);
|
||||
static void modem_gsm_network_init (MMModemGsmNetwork *gsm_network_class);
|
||||
@@ -534,7 +534,7 @@ send_huawei_cpin_done (MMAtSerialPort *port,
|
||||
else if (strstr (pin_type, MM_MODEM_GSM_CARD_SIM_PIN2))
|
||||
num = 5;
|
||||
else {
|
||||
g_debug ("%s: unhandled pin type '%s'", __func__, pin_type);
|
||||
mm_dbg ("unhandled pin type '%s'", pin_type);
|
||||
|
||||
info->error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL, "Unhandled PIN type");
|
||||
}
|
||||
@@ -576,7 +576,7 @@ get_unlock_retries (MMModemGsmCard *modem,
|
||||
char *command;
|
||||
MMCallbackInfo *info = mm_callback_info_uint_new (MM_MODEM (modem), callback, user_data);
|
||||
|
||||
g_debug ("%s: pin type '%s'", __func__, pin_type);
|
||||
mm_dbg ("pin type '%s'", pin_type);
|
||||
|
||||
/* Ensure we have a usable port to use for the command */
|
||||
port = mm_generic_gsm_get_best_at_port (MM_GENERIC_GSM (modem), &info->error);
|
||||
@@ -660,12 +660,11 @@ handle_mode_change (MMAtSerialPort *port,
|
||||
} else if (a == 0)
|
||||
act = MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
|
||||
else {
|
||||
g_warning ("Couldn't parse mode change value: '%s'", str);
|
||||
mm_warn ("Couldn't parse mode change value: '%s'", str);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mm_options_debug ())
|
||||
g_debug ("Access Technology: %d", act);
|
||||
mm_dbg ("Access Technology: %d", act);
|
||||
|
||||
mm_generic_gsm_update_access_technology (MM_GENERIC_GSM (self), act);
|
||||
}
|
||||
@@ -680,10 +679,8 @@ handle_status_change (MMAtSerialPort *port,
|
||||
|
||||
str = g_match_info_fetch (match_info, 1);
|
||||
if (sscanf (str, "%x,%x,%x,%x,%x,%x,%x", &n1, &n2, &n3, &n4, &n5, &n6, &n7)) {
|
||||
if (mm_options_debug ()) {
|
||||
g_debug ("Duration: %d Up: %d Kbps Down: %d Kbps Total: %d Total: %d\n",
|
||||
n1, n2 * 8 / 1000, n3 * 8 / 1000, n4 / 1024, n5 / 1024);
|
||||
}
|
||||
mm_dbg ("Duration: %d Up: %d Kbps Down: %d Kbps Total: %d Total: %d\n",
|
||||
n1, n2 * 8 / 1000, n3 * 8 / 1000, n4 / 1024, n5 / 1024);
|
||||
}
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "mm-at-serial-port.h"
|
||||
#include "mm-generic-gsm.h"
|
||||
#include "mm-modem-helpers.h"
|
||||
#include "mm-log.h"
|
||||
|
||||
struct _MMModemIceraPrivate {
|
||||
/* Pending connection attempt */
|
||||
@@ -325,7 +326,7 @@ icera_disconnect_done (MMModem *modem,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_message ("Modem signaled disconnection from the network");
|
||||
mm_info ("Modem signaled disconnection from the network");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -380,7 +381,7 @@ connection_enabled (MMAtSerialPort *port,
|
||||
connect_pending_done (self);
|
||||
break;
|
||||
default:
|
||||
g_warning ("Unknown Icera connect status %d", status);
|
||||
mm_warn ("Unknown Icera connect status %d", status);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Copyright (C) 2008 - 2010 Ericsson AB
|
||||
* Copyright (C) 2009 - 2010 Red Hat, Inc.
|
||||
* Copyright (C) 2009 - 2011 Red Hat, Inc.
|
||||
*
|
||||
* Author: Per Hallsmark <per.hallsmark@ericsson.com>
|
||||
* Bjorn Runaker <bjorn.runaker@ericsson.com>
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "mm-modem-gsm-card.h"
|
||||
#include "mm-errors.h"
|
||||
#include "mm-callback-info.h"
|
||||
#include "mm-log.h"
|
||||
|
||||
static void modem_init (MMModem *modem_class);
|
||||
static void modem_gsm_network_init (MMModemGsmNetwork *gsm_network_class);
|
||||
@@ -410,7 +411,7 @@ mbm_emrdy_done (MMAtSerialPort *port,
|
||||
MMModemMbmPrivate *priv = MM_MODEM_MBM_GET_PRIVATE (info->modem);
|
||||
|
||||
if (g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT))
|
||||
g_warning ("%s: timed out waiting for EMRDY response.", __func__);
|
||||
mm_warn ("timed out waiting for EMRDY response.");
|
||||
else
|
||||
priv->have_emrdy = TRUE;
|
||||
|
||||
@@ -632,16 +633,16 @@ mbm_e2nap_received (MMAtSerialPort *port,
|
||||
g_free (str);
|
||||
|
||||
if (MBM_E2NAP_DISCONNECTED == state) {
|
||||
g_debug ("%s: disconnected", __func__);
|
||||
mm_dbg ("disconnected");
|
||||
mbm_do_connect_done (MM_MODEM_MBM (user_data), FALSE);
|
||||
} else if (MBM_E2NAP_CONNECTED == state) {
|
||||
g_debug ("%s: connected", __func__);
|
||||
mm_dbg ("connected");
|
||||
mbm_do_connect_done (MM_MODEM_MBM (user_data), TRUE);
|
||||
} else if (MBM_E2NAP_CONNECTING == state)
|
||||
g_debug("%s: connecting", __func__);
|
||||
mm_dbg ("connecting");
|
||||
else {
|
||||
/* Should not happen */
|
||||
g_debug("%s: unhandled E2NAP state %d", __func__, state);
|
||||
mm_dbg ("unhandled E2NAP state %d", state);
|
||||
mbm_do_connect_done (MM_MODEM_MBM (user_data), FALSE);
|
||||
}
|
||||
}
|
||||
@@ -811,7 +812,7 @@ send_epin_done (MMAtSerialPort *port,
|
||||
else if (strstr (pin_type, MM_MODEM_GSM_CARD_SIM_PUK2))
|
||||
sscanf (response->str, "*EPIN: %*d, %*d, %*d, %d", &attempts_left);
|
||||
else {
|
||||
g_debug ("%s: unhandled pin type '%s'", __func__, pin_type);
|
||||
mm_dbg ("unhandled pin type '%s'", pin_type);
|
||||
|
||||
info->error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL, "Unhandled PIN type");
|
||||
}
|
||||
@@ -838,7 +839,7 @@ mbm_get_unlock_retries (MMModemGsmCard *modem,
|
||||
char *command;
|
||||
MMCallbackInfo *info = mm_callback_info_uint_new (MM_MODEM (modem), callback, user_data);
|
||||
|
||||
g_debug ("%s: pin type '%s'", __func__, pin_type);
|
||||
mm_dbg ("pin type '%s'", pin_type);
|
||||
|
||||
/* Ensure we have a usable port to use for the command */
|
||||
port = mm_generic_gsm_get_best_at_port (MM_GENERIC_GSM (modem), &info->error);
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "mm-generic-cdma.h"
|
||||
#include "mm-errors.h"
|
||||
#include "mm-serial-parsers.h"
|
||||
#include "mm-log.h"
|
||||
|
||||
G_DEFINE_TYPE (MMPluginGeneric, mm_plugin_generic, MM_TYPE_PLUGIN_BASE)
|
||||
|
||||
@@ -127,10 +128,10 @@ grab_port (MMPluginBase *base,
|
||||
g_set_error (error, 0, 0, "Could not get port's sysfs file.");
|
||||
return NULL;
|
||||
} else {
|
||||
g_message ("%s: (%s/%s) WARNING: missing udev 'device' file",
|
||||
mm_plugin_get_name (MM_PLUGIN (base)),
|
||||
subsys,
|
||||
name);
|
||||
mm_warn ("%s: (%s/%s) WARNING: missing udev 'device' file",
|
||||
mm_plugin_get_name (MM_PLUGIN (base)),
|
||||
subsys,
|
||||
name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "mm-modem-huawei-cdma.h"
|
||||
#include "mm-serial-parsers.h"
|
||||
#include "mm-at-serial-port.h"
|
||||
#include "mm-log.h"
|
||||
|
||||
G_DEFINE_TYPE (MMPluginHuawei, mm_plugin_huawei, MM_TYPE_PLUGIN_BASE)
|
||||
|
||||
@@ -240,10 +241,10 @@ supports_port (MMPluginBase *base,
|
||||
info->id = g_timeout_add_seconds (7, probe_secondary_timeout, task);
|
||||
|
||||
if (!mm_serial_port_open (MM_SERIAL_PORT (info->serial), &error)) {
|
||||
g_warning ("%s: (Huawei) %s: couldn't open serial port: (%d) %s",
|
||||
__func__, name,
|
||||
error ? error->code : -1,
|
||||
error && error->message ? error->message : "(unknown)");
|
||||
mm_warn ("(Huawei) %s: couldn't open serial port: (%d) %s",
|
||||
name,
|
||||
error ? error->code : -1,
|
||||
error && error->message ? error->message : "(unknown)");
|
||||
g_clear_error (&error);
|
||||
huawei_supports_info_destroy (info);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
||||
@@ -84,7 +84,7 @@ supports_port (MMPluginBase *base,
|
||||
|
||||
client = g_udev_client_new (sys);
|
||||
if (!client) {
|
||||
g_warning ("mbm: could not get udev client.");
|
||||
g_warn_if_fail (client != NULL);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user