/* ***********************IMPORTANT *********************************************
 *  Copyright (C) 2004-2007 Thierry Lagarde <tlagarde@users.sourceforge.net>
 *  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 2 of the License.
 *
 *
 *                      ********************
 *
 *
 *  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 Library General Public License for more details.
 *
 *
 *                      ********************
 *
 *
 * You are highly encouraged to send your changes to <tlagarde@users.sourceforge.net>
 * for possible incorporation into the main distribution.
 * By sending these changes to <tlagarde@users.sourceforge.net>,
 * it is assumed that you are offering <tlagarde@users.sourceforge.net>
 * the unlimited, non-exclusive right to reuse, modify, and relicense the code.
 *
 *
 *                      ********************
 *
 *  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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **************************************************************************************/
#ifndef         __LOG
#define         __LOG

#include <glib.h>

enum enum_Categorie_Debug {
	CATEG_MAIN = 0,
	CATEG_THREAD_CONTRIBUTION,
	CATEG_THREAD_SOUND,
	CATEG_THREAD_TEST_VERSION,
	CATEG_THREAD_ENVOIE_EMAIL,
	CATEG_THREAD_UPDATE_FINGERPRINTING,
	CATEG_COMM_SEND,
	CATEG_COMM_RECV,
	NB_CATEGORIE_DEBUG
};

struct Struct_Categorie {
	gint      Categorie;
	gchar    *Info;
	gchar	 *Fichier_Log;
	int       ID_Fichier_Log;
	gint	  used;	
	gboolean  deja_ouvert;
};

struct struct_Cle_Privee {
	gint      Categorie;
	void     *Pointeur_Data;// Utiliser pour stocker par exemple le pointeur de l'équipement
	int       ID_Fichier_Log;  
};
struct struct_Cle_Privee *Donnee_Cle_Main;
	

#ifdef __LOG_ENABLE
#include <glib.h>
#include "Thread.h"

#define REPERTOIRE_LOG  "%s/.autoscan-network/log/"


pthread_key_t Cle_privee_thread;
pthread_once_t once_cle_privee;


void 	Initialisation_Log (void);
void      create_cle_privee (void);
void Log (struct struct_Cle_Privee *Donnee_Cle,gchar *Log);
struct struct_Cle_Privee *Create_Log (gint Categorie,gchar *name,void *Data,gboolean Attache_Thread);
void Close_Log_Thread (struct struct_Cle_Privee *Donnee_Cle);
void Ckeck_Fermeture_Log ();
void Close_Log_Main();
void Initialisation_Repertoire_Log();
void Envoie_Email_Segfault(struct struct_Cle_Privee *pCle);
void Log_free (struct struct_Cle_Privee *Donnee_Cle,gchar *Texte);
#endif

#endif
