Commit 9afb4b47 authored by Julien Bonjean's avatar Julien Bonjean

Introduced log4c (ticket #1162)

parent 0483da3d
<?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="notice"/>
<category name="org.sflphone.gtk" priority="warning" appender="stdout" />
</log4c>
......@@ -6,6 +6,7 @@ SUBDIRS = config contacts dbus
NOFIFY_LIBS = -lnotify
SEXY_LIBS = -lsexy
LOG4C = -llog4c
SFLPHONEGTK_LIBS=./contacts/libcontacts.la ./config/libconfig.la ./dbus/libdbus.la
......@@ -34,7 +35,7 @@ noinst_HEADERS = actions.h sflnotify.h mainwindow.h dialpad.h codeclist.h \
EXTRA_DIST = marshaller.list
sflphone_gtk_LDADD = $(DEPS_LIBS) $(NOTIFY_LIBS) $(SEXY_LIBS) $(SFLPHONEGTK_LIBS)
sflphone_gtk_LDADD = $(DEPS_LIBS) $(NOTIFY_LIBS) $(SEXY_LIBS) $(SFLPHONEGTK_LIBS) $(LOG4C)
# add symbolic link
install-exec-local:
......
......@@ -27,86 +27,124 @@
#include <gtk/gtk.h>
#include <stdlib.h>
#include "log4c.h"
static log4c_category_t* log4c_global_category = NULL;
static void
startup_logging()
{
log4c_init();
log4c_global_category = log4c_category_get("org.sflphone.gtk");
}
static void
shutdown_logging()
{
if (log4c_fini())
{
printf("log4c_fini() failed");
}
}
int
main (int argc, char *argv[])
main(int argc, char *argv[])
{
gtk_init (&argc, &argv);
// Handle logging
int i;
startup_logging();
for (i = 0; i < argc; i++)
if (g_strcmp0(argv[i], "--debug") == 0)
log4c_category_set_priority(log4c_global_category, LOG4C_PRIORITY_DEBUG);
// Start GTK application
gtk_init(&argc, &argv);
g_print("%s\n", PACKAGE_STRING);
g_print("Copyright (c) 2005 2006 2007 2008 2009 Savoir-faire Linux Inc.\n");
g_print("This is free software. You may redistribute copies of it under the terms of\n\
g_print(
"This is free software. You may redistribute copies of it under the terms of\n\
the GNU General Public License Version 3 <http://www.gnu.org/licenses/gpl.html>.\n\
There is NO WARRANTY, to the extent permitted by law.\n\n");
srand ( time(NULL) );
DEBUG("Logging Started");
srand(time(NULL));
// Internationalization
bindtextdomain( "sflphone" , "/usr/share/locale" );
textdomain( "sflphone" );
if(sflphone_init())
{
#if GTK_CHECK_VERSION(2,10,0)
show_status_icon();
#endif
create_main_window ();
#if GTK_CHECK_VERSION(2,10,0)
if( dbus_is_start_hidden() )
bindtextdomain("sflphone", "/usr/share/locale");
textdomain("sflphone");
if (sflphone_init())
{
gtk_widget_hide(GTK_WIDGET( get_main_window() ));
set_minimized( TRUE );
#if GTK_CHECK_VERSION(2,10,0)
show_status_icon();
#endif
create_main_window();
#if GTK_CHECK_VERSION(2,10,0)
if (dbus_is_start_hidden())
{
gtk_widget_hide(GTK_WIDGET( get_main_window() ));
set_minimized(TRUE);
}
#endif
status_bar_display_account();
/* start the main loop */
gtk_main();
}
#endif
status_bar_display_account ();
// Cleanly stop logging
shutdown_logging();
/* start the main loop */
gtk_main ();
}
return 0;
}
/** @mainpage SFLphone GTK+ Client Documentation
* SFLphone GTK+ Client was started as a debuging tool for the new dbus API but
* ended being a full featured client.
* @section intro_sec Architecture
* SFLphone respects the MVC principle. Since the internal workings and the UI
* are too different programs, dbus is used to exchange data between them. Dbus
* is thereby inforcing MVC by only allowing access to high level functions and data.
*
* Therefore, when a button is clicked, a direct dbus API call should happen
* (defined in dbus.h). The UI should only be updated when signals are received
* from dbus. The call back to those signals are defined in dbus.c, but they call
* functions in actions.h. This makes things cleaner as one signal could have many
* actions.
*
* Accounts are stored in form of a account_t in an account list with access functions
* defined in accountlist.h.
*
* Calls are stored in form of a call_t in a call list with access functions defined
* in calllist.h.
*
*/
* SFLphone GTK+ Client was started as a debuging tool for the new dbus API but
* ended being a full featured client.
* @section intro_sec Architecture
* SFLphone respects the MVC principle. Since the internal workings and the UI
* are too different programs, dbus is used to exchange data between them. Dbus
* is thereby inforcing MVC by only allowing access to high level functions and data.
*
* Therefore, when a button is clicked, a direct dbus API call should happen
* (defined in dbus.h). The UI should only be updated when signals are received
* from dbus. The call back to those signals are defined in dbus.c, but they call
* functions in actions.h. This makes things cleaner as one signal could have many
* actions.
*
* Accounts are stored in form of a account_t in an account list with access functions
* defined in accountlist.h.
*
* Calls are stored in form of a call_t in a call list with access functions defined
* in calllist.h.
*
*/
// This doc is for generated files that get overridden by tools.
/** @file marshaller.h
* @brief This file contains marshallers functions for dbus signals.
* This file is generated by glib-genmarshall.
* Every dbus signal has to have a marshaller. To generate a new marshaller function,
* add its signature to the marshaller.list. Then run :
* <pre>glib-genmarshal --body --g-fatal-warnings marshaller.list > marshaller.c
* glib-genmarshal --header --g-fatal-warnings marshaller.list > marshaller.h</pre>
* to get the generated marshallers.
* Just before connecting to the dbus signal, register the marshaller with:
* dbus_g_object_register_marshaller().
*/
* @brief This file contains marshallers functions for dbus signals.
* This file is generated by glib-genmarshall.
* Every dbus signal has to have a marshaller. To generate a new marshaller function,
* add its signature to the marshaller.list. Then run :
* <pre>glib-genmarshal --body --g-fatal-warnings marshaller.list > marshaller.c
* glib-genmarshal --header --g-fatal-warnings marshaller.list > marshaller.h</pre>
* to get the generated marshallers.
* Just before connecting to the dbus signal, register the marshaller with:
* dbus_g_object_register_marshaller().
*/
/** @file callmanager-glue.h, configurationmanager-glue.h, contactmanager-glue.h
* @brief CallManager, ConfigurationManager and ContactManager dbus APIs.
* These files are generated by dbus-binding-tool using the server's files named *-introspec.xml:
* <pre>dbus-binding-tool --mode=glib-client "../../src/dbus/callmanager-introspec.xml" > callmanager-glue.h</pre>
* <pre>dbus-binding-tool --mode=glib-client "../../src/dbus/configurationmanager-introspec.xml" > configurationmanager-glue.h</pre>
* <pre>dbus-binding-tool --mode=glib-client "../../src/dbus/contactmanager-introspec.xml" > contactmanager-glue.h</pre>
* These files dbus call wrapper functions to simplify access to dbus API.
*/
* @brief CallManager, ConfigurationManager and ContactManager dbus APIs.
* These files are generated by dbus-binding-tool using the server's files named *-introspec.xml:
* <pre>dbus-binding-tool --mode=glib-client "../../src/dbus/callmanager-introspec.xml" > callmanager-glue.h</pre>
* <pre>dbus-binding-tool --mode=glib-client "../../src/dbus/configurationmanager-introspec.xml" > configurationmanager-glue.h</pre>
* <pre>dbus-binding-tool --mode=glib-client "../../src/dbus/contactmanager-introspec.xml" > contactmanager-glue.h</pre>
* These files dbus call wrapper functions to simplify access to dbus API.
*/
/*
* Copyright (C) 2008 Savoir-Faire Linux inc.
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
*
* Author: Emmanuel Milou <emmanuel.milou@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.
......@@ -28,7 +28,7 @@
*/
/** Locale */
#define _(STRING) gettext( STRING )
#define _(STRING) gettext( STRING )
/** Warnings unused variables **/
#define UNUSED_VAR(var) (void*)var
......@@ -52,10 +52,8 @@
/** Error pulseaudio */
#define PULSEAUDIO_NOT_RUNNING 0x0100
/** Tone to play when no voice mails */
#define TONE_WITHOUT_MESSAGE 0
#define TONE_WITHOUT_MESSAGE 0
/** Tone to play when voice mails */
#define TONE_WITH_MESSAGE 1
/** Tells if the main window is reduced to the system tray or not */
......@@ -63,11 +61,11 @@
/** Behaviour of the main window on incoming calls */
#define __POPUP_WINDOW ( dbus_popup_mode() )
/** Show/Hide the dialpad */
#define SHOW_DIALPAD ( dbus_get_dialpad() )
#define SHOW_DIALPAD ( dbus_get_dialpad() )
/** Show/Hide the volume controls */
#define SHOW_VOLUME ( dbus_get_volume_controls() )
#define SHOW_VOLUME ( dbus_get_volume_controls() )
/** Show/Hide the dialpad */
#define SHOW_SEARCHBAR ( dbus_get_searchbar() )
#define SHOW_SEARCHBAR ( dbus_get_searchbar() )
/** Show/Hide the alsa configuration panel */
#define SHOW_ALSA_CONF ( dbus_get_audio_manager() == ALSA )
......@@ -81,7 +79,7 @@
#define __NOTIF_LEVEL_HIGH 2
/** Messages ID for the status bar - Incoming calls */
#define __MSG_INCOMING_CALL 0
#define __MSG_INCOMING_CALL 0
/** Messages ID for the status bar - Calling */
#define __MSG_CALLING 1
/** Messages ID for the status bar - Voice mails notification */
......@@ -93,6 +91,17 @@
#define __TIMEOUT_MODE "default"
/** Desktop notifications - Time before to close the notification*/
#define __TIMEOUT_TIME 18000 // 30 secondes
/**
* Macros for logging
*/
#define TRACE(...) log4c_category_log(log4c_global_category, LOG4C_PRIORITY_TRACE, __VA_ARGS__);
#define DEBUG(...) log4c_category_log(log4c_global_category, LOG4C_PRIORITY_DEBUG, __VA_ARGS__);
#define INFO(...) log4c_category_log(log4c_global_category, LOG4C_PRIORITY_INFO, __VA_ARGS__);
#define NOTICE(...) log4c_category_log(log4c_global_category, LOG4C_PRIORITY_NOTICE, __VA_ARGS__);
#define WARN(...) log4c_category_log(log4c_global_category, LOG4C_PRIORITY_WARN, __VA_ARGS__);
#define ERROR(...) log4c_category_log(log4c_global_category, LOG4C_PRIORITY_ERROR, __VA_ARGS__);
#define CRIT(...) log4c_category_log(log4c_global_category, LOG4C_PRIORITY_CRIT, __VA_ARGS__);
#define ALERT(...) log4c_category_log(log4c_global_category, LOG4C_PRIORITY_ALERT, __VA_ARGS__);
#define FATAL(...) log4c_category_log(log4c_global_category, LOG4C_PRIORITY_FATAL, __VA_ARGS__);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment