diff --git a/sflphone-client-gnome/Makefile.am b/sflphone-client-gnome/Makefile.am index 7b944d233160c5d75d56f3f75104a4fbe54ca3fc..e6696e170ddc9143a6f134554035c0a866534c59 100644 --- a/sflphone-client-gnome/Makefile.am +++ b/sflphone-client-gnome/Makefile.am @@ -6,16 +6,13 @@ GCONFTOOL=gconftool-2 GNOME_DOC=gnome-doc-utils.make -log4crc_DATA = log4crc -log4crcdir = $(datadir)/sflphone - uidir=$(datadir)/sflphone/ui ui_DATA=src/ui.xml schemadir = @GCONF_SCHEMA_FILE_DIR@ schema_DATA = sflphone-client-gnome.schemas -EXTRA_DIST = $(log4crc_DATA) sflphone.desktop.in $(GNOME_DOC) m4 $(UI_DATA) $(schema_DATA) +EXTRA_DIST = sflphone.desktop.in $(GNOME_DOC) m4 $(UI_DATA) $(schema_DATA) appsdir = $(datadir)/applications apps_in_files = sflphone.desktop.in apps_DATA = $(apps_in_files:.desktop.in=.desktop) diff --git a/sflphone-client-gnome/configure.ac b/sflphone-client-gnome/configure.ac index 44f118f5391ac8dff8b6841324c886d691fe6f6d..be6faac5149766bc9e3ddc0d19cbac75ef6fdd97 100644 --- a/sflphone-client-gnome/configure.ac +++ b/sflphone-client-gnome/configure.ac @@ -35,12 +35,6 @@ AC_PROG_LIBTOOL dnl GCONF utilities AM_GCONF_SOURCE_2 -dnl Check for log4c -AC_CHECK_HEADERS(log4c.h, have_log4c=true, have_log4c=false) -if ! $have_log4c; then - AC_MSG_ERROR(Please install the log4c library) -fi - dnl uninstalled gsr ui dir AC_DEFINE_UNQUOTED(SFLPHONE_UIDIR_UNINSTALLED, "`pwd`/src/", [path to uninstalled SFLphone UI dir]) diff --git a/sflphone-client-gnome/log4crc b/sflphone-client-gnome/log4crc deleted file mode 100644 index e108c9378b0e99e095389c63d029db54a1791290..0000000000000000000000000000000000000000 --- a/sflphone-client-gnome/log4crc +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE log4c SYSTEM ""> - -<log4c version="1.2.1"> - <config> - <bufsize>0</bufsize> - <debug level="2"/> - <nocleanup>0</nocleanup> - <reread>1</reread> - </config> - - <rollingpolicy name="rollingpolicy" type="sizewin" maxsize="1024" maxnum="10" /> - <appender name="rollingfileappender" type="rollingfile" logdir="." prefix="prefix" layout="dated" rollingpolicy="rollingpolicy" /> - - <appender name="stdout" type="stream" layout="basic"/> - <appender name="stderr" type="stream" layout="dated"/> - <appender name="syslog" type="syslog" layout="basic"/> - - <layout name="basic" type="basic"/> - <layout name="dated" type="dated"/> - - <category name="root" priority="warning"/> - <category name="org.sflphone.gtk" priority="warning" appender="stdout" /> -</log4c> diff --git a/sflphone-client-gnome/src/Makefile.am b/sflphone-client-gnome/src/Makefile.am index bbb6b0a31cb7e779d4394e2a4f1c9ec53bd9faf4..57fb2e4689c4b90983255c477e6aa014e40f4ea7 100644 --- a/sflphone-client-gnome/src/Makefile.am +++ b/sflphone-client-gnome/src/Makefile.am @@ -5,7 +5,6 @@ bin_PROGRAMS = sflphone-client-gnome SUBDIRS = config contacts dbus widget icons NOFIFY_LIBS = -lnotify -LOG4C = -llog4c X11_LIBS = -lX11 SFLPHONEGTK_LIBS=./contacts/libcontacts.la ./config/libconfig.la ./dbus/libdbus.la ./widget/libwidget.la ./icons/libicons.la @@ -13,6 +12,7 @@ SFLPHONEGTK_LIBS=./contacts/libcontacts.la ./config/libconfig.la ./dbus/libdbus. sflphone_client_gnome_SOURCES = \ main.c \ errors.c \ + logger.c \ uimanager.c \ sflnotify.c \ mainwindow.c \ @@ -31,9 +31,9 @@ sflphone_client_gnome_SOURCES = \ noinst_HEADERS = actions.h sflnotify.h mainwindow.h dialpad.h codeclist.h \ reqaccount.h errors.h sflphone_const.h uimanager.h \ accountlist.h sliders.h statusicon.h callable_obj.h conference_obj.h \ - shortcuts.h eel-gconf-extensions.h + shortcuts.h eel-gconf-extensions.h logger.h -sflphone_client_gnome_LDADD = $(DEPS_LIBS) $(NOTIFY_LIBS) $(SFLPHONEGTK_LIBS) $(LIBSEXY_LIBS) $(LOG4C) $(X11_LIBS) +sflphone_client_gnome_LDADD = $(DEPS_LIBS) $(NOTIFY_LIBS) $(SFLPHONEGTK_LIBS) $(LIBSEXY_LIBS) $(X11_LIBS) # add symbolic link install-exec-local: diff --git a/sflphone-client-gnome/src/config/accountconfigdialog.c b/sflphone-client-gnome/src/config/accountconfigdialog.c index 922b4a9aed40e18862038d0dd5a4e8ee84111746..0cfd91f7a86ae120178ca57d17ac843986c3f7b7 100644 --- a/sflphone-client-gnome/src/config/accountconfigdialog.c +++ b/sflphone-client-gnome/src/config/accountconfigdialog.c @@ -193,7 +193,7 @@ static GPtrArray* getNewCredential (GHashTable * properties) { DEBUG("shit"); if(valid == FALSE) { - DEBUG("Gtk tree model iter is not valid") + DEBUG("Gtk tree model iter is not valid"); return NULL; } @@ -1182,7 +1182,7 @@ GtkWidget* create_published_address (account_t **a) { GtkWidget* create_advanced_tab (account_t **a) { // Build the advanced tab, to appear on the account configuration panel - DEBUG("Config: Build advanced tab") + DEBUG("Config: Build advanced tab"); GtkWidget *ret, *frame; diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c index 6417d628fb4775731f2354fde2ac82ba910c61e6..5488e3f03e20b0c461400b0e9b6f4f08a1a913d8 100644 --- a/sflphone-client-gnome/src/contacts/calltree.c +++ b/sflphone-client-gnome/src/contacts/calltree.c @@ -414,7 +414,7 @@ calltree_display_call_info(callable_obj_t * c, CallDisplayType display_type, gch case DISPLAY_TYPE_CALL_TRANSFER: - DEBUG("CallTree: Display a call transfer") + DEBUG("CallTree: Display a call transfer"); if(g_strcmp0("",c->_peer_name) == 0){ description = g_markup_printf_escaped("<b>%s</b><i>%s</i>\n<i>Transfert to:%s</i> ", @@ -902,7 +902,7 @@ void calltree_add_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) } } - DEBUG("Added call key exchange is %s", key_exchange) + DEBUG("Added call key exchange is %s", key_exchange); if( tab == current_calls ) { diff --git a/sflphone-client-gnome/src/logger.c b/sflphone-client-gnome/src/logger.c new file mode 100644 index 0000000000000000000000000000000000000000..d68c2402e34807ed151b81a625a5c0c31c61ca83 --- /dev/null +++ b/sflphone-client-gnome/src/logger.c @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. + * Author: Julien Bonjean <julien.bonjean@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Additional permission under GNU GPL version 3 section 7: + * + * If you modify this program, or any covered work, by linking or + * combining it with the OpenSSL project's OpenSSL library (or a + * modified version of that library), containing parts covered by the + * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. + * grants you additional permission to convey the resulting work. + * Corresponding Source for a non-source form of such a combination + * shall include the source code for the parts of OpenSSL used as well + * as that of the covered work. + */ + +#include <logger.h> +#include <stdarg.h> +#include <string.h> +#include <stdio.h> + +int log_level = LOG_INFO; + +void internal_log(const int level, const char* format, ...) +{ + if(level > log_level) + return; + + printf("%d\n",level); + printf("%d\n",log_level); + + va_list ap; + char *prefix = "<> "; + char buffer[4000]; + char message[4096]; + + switch(level) + { + case LOG_ERR: + { + prefix = "<error> "; + break; + } + case LOG_WARN: + { + prefix = "<warning> "; + break; + } + case LOG_INFO: + { + prefix = "<info> "; + break; + } + case LOG_DEBUG: + { + prefix = "<debug> "; + break; + } + } + + va_start(ap, format); + vsprintf(buffer, format, ap); + va_end(ap); + + message[0] = '\0'; + strncat(message, prefix, strlen(prefix)); + strncat(message, buffer, strlen(buffer)); + strncat(message, "\n", 1); + + fprintf(stderr, "%s", message); +} + +void set_log_level(const int level) +{ + log_level = level; +} diff --git a/sflphone-client-gnome/src/logger.h b/sflphone-client-gnome/src/logger.h new file mode 100644 index 0000000000000000000000000000000000000000..e445e981e3d80106ac68f6d7a71dd007ab10b8a1 --- /dev/null +++ b/sflphone-client-gnome/src/logger.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. + * Author: Julien Bonjean <julien.bonjean@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Additional permission under GNU GPL version 3 section 7: + * + * If you modify this program, or any covered work, by linking or + * combining it with the OpenSSL project's OpenSSL library (or a + * modified version of that library), containing parts covered by the + * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. + * grants you additional permission to convey the resulting work. + * Corresponding Source for a non-source form of such a combination + * shall include the source code for the parts of OpenSSL used as well + * as that of the covered work. + */ + +#ifndef __LOGGER_H +#define __LOGGER_H + +void internal_log(const int level, const char* format, ...); +void set_log_level(const int level); + +#define LOG_ERR 1 +#define LOG_WARN 2 +#define LOG_INFO 3 +#define LOG_DEBUG 4 + +#define ERROR(...) internal_log(LOG_ERR, __VA_ARGS__) +#define WARN(...) internal_log(LOG_WARN, __VA_ARGS__) +#define INFO(...) internal_log(LOG_INFO, __VA_ARGS__) +#define DEBUG(...) internal_log(LOG_DEBUG, __VA_ARGS__) + +#endif diff --git a/sflphone-client-gnome/src/main.c b/sflphone-client-gnome/src/main.c index 38cb5cd3f7a05b423116e4727294c168277a414d..5b9baa7d42a67d23f00678fd893781b16fc1e203 100644 --- a/sflphone-client-gnome/src/main.c +++ b/sflphone-client-gnome/src/main.c @@ -31,6 +31,7 @@ #include <actions.h> #include <calllist.h> #include <config.h> +#include <logger.h> #include <dbus/dbus.h> #include <mainwindow.h> #include <statusicon.h> @@ -42,44 +43,16 @@ #include "shortcuts.h" -/** - * Stop logging engine - */ -static void -shutdown_logging () -{ - if (log4c_fini ()) - { - ERROR("log4c_fini() failed"); - } -} - -/** - * Start loggin engine - */ -static void -startup_logging () -{ - log4c_init (); - if (log4c_load (DATA_DIR "/log4crc") == -1) - g_warning ("Cannot load log4j configuration file : %s", DATA_DIR "/log4crc"); - - log4c_sfl_gtk_category = log4c_category_get ("org.sflphone.gtk"); -} - int main (int argc, char *argv[]) { // Handle logging int i; - // Startup logging - startup_logging (); - // Check arguments if debug mode is activated for (i = 0; i < argc; i++) if (g_strcmp0 (argv[i], "--debug") == 0) - log4c_category_set_priority (log4c_sfl_gtk_category, LOG4C_PRIORITY_DEBUG); + set_log_level (LOG_DEBUG); // Start GTK application @@ -100,8 +73,6 @@ main (int argc, char *argv[]) "shall include the source code for the parts of OpenSSL used as well\n" \ "as that of the covered work.\n\n"); - DEBUG("Logging Started"); - srand (time (NULL)); // Internationalization @@ -146,9 +117,6 @@ main (int argc, char *argv[]) gtk_main (); } - // Cleanly stop logging - shutdown_logging (); - shortcuts_destroy_bindings(); return 0; diff --git a/sflphone-client-gnome/src/sflphone_const.h b/sflphone-client-gnome/src/sflphone_const.h index 250a8c56738456d0a351d93bdb52b27667848fe9..0f46a82cb38cb2ad4c26c1b6abcbc0833ccb7da6 100644 --- a/sflphone-client-gnome/src/sflphone_const.h +++ b/sflphone-client-gnome/src/sflphone_const.h @@ -32,8 +32,8 @@ #define __SFLPHONE_CONST_H #include <libintl.h> +#include "logger.h" #include "dbus.h" -#include "log4c.h" /* @file sflphone_const.h * @brief Contains the global variables for the client code @@ -117,11 +117,6 @@ #define REGISTRATION_STATE_CODE "Registration.code" #define REGISTRATION_STATE_DESCRIPTION "Registration.description" -/** - * Global logger - */ -log4c_category_t* log4c_sfl_gtk_category; - /** Error while opening capture device */ #define ALSA_CAPTURE_DEVICE 0x0001 /** Error while opening playback device */ @@ -169,14 +164,6 @@ log4c_category_t* log4c_sfl_gtk_category; /** Desktop notifications - Time before to close the notification*/ #define __TIMEOUT_TIME 18000 // 30 secondes -/** - * Macros for logging - */ -#define DEBUG(...) log4c_category_log(log4c_sfl_gtk_category, LOG4C_PRIORITY_DEBUG, __VA_ARGS__); -#define WARN(...) log4c_category_log(log4c_sfl_gtk_category, LOG4C_PRIORITY_WARN, __VA_ARGS__); -#define ERROR(...) log4c_category_log(log4c_sfl_gtk_category, LOG4C_PRIORITY_ERROR, __VA_ARGS__); -#define FATAL(...) log4c_category_log(log4c_sfl_gtk_category, LOG4C_PRIORITY_FATAL, __VA_ARGS__); - /** * Gconf */ diff --git a/sflphone-client-gnome/tests/Makefile.am b/sflphone-client-gnome/tests/Makefile.am index ba1161ae750bf07180fc71504a88bcf0e97dda49..3d3ffb8f4dfa7d8216f47ae495b5f310a1c76e29 100644 --- a/sflphone-client-gnome/tests/Makefile.am +++ b/sflphone-client-gnome/tests/Makefile.am @@ -27,24 +27,24 @@ SFLPHONE_OBJ = $(top_builddir)/src/accountlist.o \ check_global_SOURCES = check_global.c check_global_CFLAGS = @CHECK_CFLAGS@ @DEPS_CFLAGS@ -check_global_LDADD = $(SFLPHONE_LIBS) $(SFLPHONE_OBJ) @CHECK_LIBS@ $(DEPS_LIBS) @LIBSEXY_LIBS@ -llog4c +check_global_LDADD = $(SFLPHONE_LIBS) $(SFLPHONE_OBJ) @CHECK_LIBS@ $(DEPS_LIBS) @LIBSEXY_LIBS@ ########################################################### check_contacts_SOURCES = check_contacts.c check_contacts_CFLAGS = @CHECK_CFLAGS@ @DEPS_CFLAGS@ -check_contacts_LDADD = $(SFLPHONE_LIBS) $(SFLPHONE_OBJ) @CHECK_LIBS@ $(DEPS_LIBS) @LIBSEXY_LIBS@ -llog4c +check_contacts_LDADD = $(SFLPHONE_LIBS) $(SFLPHONE_OBJ) @CHECK_LIBS@ $(DEPS_LIBS) @LIBSEXY_LIBS@ ########################################################### check_config_SOURCES = check_config.c check_config_CFLAGS = @CHECK_CFLAGS@ @DEPS_CFLAGS@ -check_config_LDADD = $(SFLPHONE_LIBS) $(SFLPHONE_OBJ) @CHECK_LIBS@ @DEPS_LIBS@ @LIBSEXY_LIBS@ -llog4c +check_config_LDADD = $(SFLPHONE_LIBS) $(SFLPHONE_OBJ) @CHECK_LIBS@ @DEPS_LIBS@ @LIBSEXY_LIBS@ ########################################################### check_dbus_SOURCES = check_dbus.c check_dbus_CFLAGS = @CHECK_CFLAGS@ @DEPS_CFLAGS@ -check_dbus_LDADD = $(SFLPHONE_LIBS) $(SFLPHONE_OBJ) @CHECK_LIBS@ @DEPS_LIBS@ @LIBSEXY_LIBS@ -llog4c +check_dbus_LDADD = $(SFLPHONE_LIBS) $(SFLPHONE_OBJ) @CHECK_LIBS@ @DEPS_LIBS@ @LIBSEXY_LIBS@ ###########################################################