summaryrefslogtreecommitdiff
path: root/cleopatre
diff options
context:
space:
mode:
authorYacine Belkadi2011-01-12 13:54:12 +0100
committerYacine Belkadi2011-01-18 17:38:15 +0100
commitd0670b66d9874d17011c625a6acc5950faf457ac (patch)
tree52e692fdbe9bbc11d821cadba23b7cc0406905eb /cleopatre
parentdf83b066b0aa4149f7c5032508fa9df34e0636aa (diff)
cleo/app/cwmp: add utils_log() for logging from code in impl_* files
The code in the impl_* files uses the log() macro provided by utils. Originally, this macro used the logging method provided by libcwmp. The problem was that it required to include "avs/cwmp.h" and thus ruined the separation from libcwmp that impl_* tries to achieve. The present changes add a utils_log() function and get rid of the reference to libcwmp. They also fix some errors in log calls.
Diffstat (limited to 'cleopatre')
-rw-r--r--cleopatre/application/cwmp/inc/utils.h12
-rw-r--r--cleopatre/application/cwmp/src/impl_instance.c2
-rw-r--r--cleopatre/application/cwmp/src/impl_set.c2
-rw-r--r--cleopatre/application/cwmp/src/utils.c16
4 files changed, 27 insertions, 5 deletions
diff --git a/cleopatre/application/cwmp/inc/utils.h b/cleopatre/application/cwmp/inc/utils.h
index 5ce3a7a165..70a851e882 100644
--- a/cleopatre/application/cwmp/inc/utils.h
+++ b/cleopatre/application/cwmp/inc/utils.h
@@ -20,11 +20,16 @@
* MA 02111-1307 USA
*/
-#include "avs/cwmp.h"
#include "impl.h"
-#define log_debug(...) cwmp_log(DEBUG, __VA_ARGS__)
-#define log_error(...) cwmp_log(ERROR, __VA_ARGS__)
+#include <stdio.h>
+
+#define UTILS_STR(x) UTILS_STR2(x)
+#define UTILS_STR2(x) #x
+
+#define log_debug(...) log("DEBUG", __VA_ARGS__)
+#define log_error(...) log("ERROR", __VA_ARGS__)
+#define log(level_name, ...) utils_log(level_name " [" __FILE__ ":" UTILS_STR(__LINE__) "]: " __VA_ARGS__)
#define ETHERNET_INTERFACE_NAME "eth0"
#define HOMEPLUG_INTERFACE_NAME "plc0"
@@ -46,6 +51,7 @@ struct utils_net_if_stats
unsigned long tx_errors;
};
+void utils_log(const char *format, ...);
utils_status_t utils_run_command(const char *command, char * const argv[], int *exit_status);
utils_status_t utils_get_network_interface_stats(const char *network_interface_name, struct utils_net_if_stats *stats);
utils_status_t utils_get_oui(char *buffer, int buffer_size);
diff --git a/cleopatre/application/cwmp/src/impl_instance.c b/cleopatre/application/cwmp/src/impl_instance.c
index 3a8f6290e5..c18f8fd6bc 100644
--- a/cleopatre/application/cwmp/src/impl_instance.c
+++ b/cleopatre/application/cwmp/src/impl_instance.c
@@ -464,7 +464,7 @@ impl_add_instance(impl_param_id_t object_id, const char *object_name, unsigned i
if (status == IMPL_STATUS_OK)
{
- log_debug("Added instance %u", added_instance_number);
+ log_debug("Added instance %u", *added_instance_number);
}
else
{
diff --git a/cleopatre/application/cwmp/src/impl_set.c b/cleopatre/application/cwmp/src/impl_set.c
index e42628ac53..2e413f3470 100644
--- a/cleopatre/application/cwmp/src/impl_set.c
+++ b/cleopatre/application/cwmp/src/impl_set.c
@@ -95,7 +95,7 @@ complete_set_device_homeplug_interface_i_networkpassword(struct pending_device_h
}
else
{
- log_error("spidapp returned %", exit_status);
+ log_error("spidapp returned %d", exit_status);
return IMPL_STATUS_ERROR;
}
}
diff --git a/cleopatre/application/cwmp/src/utils.c b/cleopatre/application/cwmp/src/utils.c
index 0b1c56f56c..7e76db0e66 100644
--- a/cleopatre/application/cwmp/src/utils.c
+++ b/cleopatre/application/cwmp/src/utils.c
@@ -2,6 +2,7 @@
#include <ctype.h>
#include <errno.h>
+#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -15,6 +16,21 @@
#define PROC_NET_DEV "/proc/net/dev"
#define PROC_NET_DEV_LINE_BUFFER_SIZE 512
+void
+utils_log(const char *format, ...)
+{
+ /* add "\n" to the format */
+ char * newline= "\n";
+ char new_format[strlen(format) + strlen(newline) + 1];
+ strcpy(new_format, format);
+ strcat(new_format, newline);
+
+ va_list ap;
+ va_start(ap, format);
+ vfprintf(stderr, new_format, ap);
+ va_end(ap);
+}
+
utils_status_t
utils_run_command(const char *command, char * const argv[], int *exit_status) /* TODO: move to libspid ? */
{