Index: include/freeDiameter/libfdproto.h
===================================================================
--- include/freeDiameter/libfdproto.h	(revision 928)
+++ include/freeDiameter/libfdproto.h	(revision 941)
@@ -3,5 +3,5 @@
 * Author: Sebastien Decugis <sdecugis@freediameter.net>							 *
 *													 *
-* Copyright (c) 2013, WIDE Project and NICT								 *
+* Copyright (c) 2012, WIDE Project and NICT								 *
 * All rights reserved.											 *
 * 													 *
@@ -110,22 +110,23 @@
 
 /*
- * FUNCTION:	fd_log_debug_fstr
+ * FUNCTION:	fd_log
  * MACRO:	fd_log_debug
  *
  * PARAMETERS:
- *  fstr	: Stream where the text will be sent (default: stdout) 
+ *  loglevel	: Integer, how important the message is
  *  format 	: Same format string as in the printf function
  *  ...		: Same list as printf
  *
  * DESCRIPTION: 
- *  Log internal information for use of developpers only.
+ * Write information to log.
  * The format and arguments may contain UTF-8 encoded data. The
- * output medium (file or console) is expected to support this encoding.
+ * output medium is expected to support this encoding.
  *
  * RETURN VALUE:
  *  None.
  */
-void fd_log_debug_fstr ( FILE * fstr, const char * format, ... );
-#define fd_log_debug(format,args...) fd_log_debug_fstr(NULL, format, ## args)
+void fd_log ( int, const char *, ... );
+#define fd_log_debug(format,args...) fd_log(FD_LOG_DEBUG, format, ## args)
+void fd_log_debug_fstr( FILE *, const char *, ... );
 
 /* these are internal objects of the debug facility, 
@@ -174,5 +175,5 @@
  *
  * PARAMETERS:
- *  fstr        : Stream where the text will be sent to (default: stdout)
+ *  loglevel    : priority of the message
  *  format      : Same format string as in the printf function
  *  va_list     : Argument list
@@ -184,5 +185,5 @@
  * int          : Success or failure
  */
-int fd_log_handler_register ( void (*logger)(const char * format, va_list *args) );
+int fd_log_handler_register ( void (*logger)(int loglevel, const char * format, va_list args) );
 
 /*
@@ -209,5 +210,9 @@
 #endif /* ASSERT */
 
-/* levels definitions */
+/* log levels definitions */
+#define FD_LOG_DEBUG 0
+#define FD_LOG_ERROR 5
+
+/* print level definitions */
 #define NONE 0	/* Display no debug message */
 #define INFO 1	/* Display errors only */
@@ -264,6 +269,6 @@
 		char __buf[25];													\
 		const char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");					\
-		fd_log_debug("\t | tid:%-20s\t%s\tin %s@%s:%d\n"								\
-			  "\t%s|%*s" format "\n",  										\
+		fd_log(level, "\t | tid:%-20s\t%s\tin %s@%s:%d\n"  \
+			  "\t%s|%*s" format,  										\
 					__thn, fd_log_time(NULL, __buf, sizeof(__buf)), __PRETTY_FUNCTION__, __FILE__, __LINE__,\
 					(level < FULL)?"@":" ",level, "", ## args); 						\
@@ -277,10 +282,10 @@
 			char __buf[25];													\
 			const char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");					\
-			fd_log_debug("\t | tid:%-20s\t%s\tin %s@%s:%d\n"								\
-				  "\t%s|%*s" format "\n",  										\
+			fd_log(level, "\t | tid:%-20s\t%s\tin %s@%s:%d\n" \
+				  "\t%s|%*s" format,  										\
 						__thn, fd_log_time(NULL, __buf, sizeof(__buf)), __PRETTY_FUNCTION__, __FILE__, __LINE__,\
 						(level < FULL)?"@":" ",level, "", ## args); 						\
 		} else {														\
-			fd_log_debug(format "\n", ## args); 										\
+			fd_log(level, format, ## args);           \
 		}															\
 	}																\
@@ -321,12 +326,12 @@
 		uint8_t * __buf = (uint8_t *)(buf);										\
 		char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");					\
-		fd_log_debug("\t | tid:%-20s\t%s\tin %s@%s:%d\n"								\
+		fd_log(level, "\t | tid:%-20s\t%s\tin %s@%s:%d\n"  \
 			  "\t%s|%*s" prefix ,  											\
 					__thn, fd_log_time(NULL, __ts, sizeof(__ts)), __PRETTY_FUNCTION__, __FILE__, __LINE__,	\
 					(level < FULL)?"@":" ",level, ""); 							\
 		for (__i = 0; __i < __sz; __i++) {										\
-			fd_log_debug("%02.2hhx", __buf[__i]);									\
+			fd_log(level, "%02.2hhx", __buf[__i]);         \
 		}														\
-		fd_log_debug(suffix "\n");											\
+		fd_log(level, suffix);                        \
 	}															\
 }
@@ -357,9 +362,9 @@
 			flag);					\
 	  if (__rc)						\
-	  	fd_log_debug("%s", (char *)gai_strerror(__rc));	\
+		fd_log_debug("%s", (char *)gai_strerror(__rc));	\
 	  else							\
-	  	fd_log_debug("%s", &__addrbuf[0]);		\
+		fd_log_debug("%s", &__addrbuf[0]);		\
 	} else {						\
-		fd_log_debug("(NULL / ANY)");			\
+		fd_log_debug("(NULL / ANY)");                   \
 	}							\
 }
@@ -378,7 +383,7 @@
 			flag);						\
 	  if (__rc)							\
-	  	fd_log_debug("%s", (char *)gai_strerror(__rc));		\
+		fd_log_debug("%s", (char *)gai_strerror(__rc));		\
 	  else								\
-	  	fd_log_debug("[%s]:%s", &__addrbuf[0],&__servbuf[0]);	\
+		fd_log_debug("[%s]:%s", &__addrbuf[0],&__servbuf[0]);	\
 	} else {							\
 		fd_log_debug("(NULL / ANY)");				\
@@ -391,10 +396,10 @@
 		char __buf[25];													\
 		char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");					\
-		fd_log_debug("\t | tid:%-20s\t%s\tin %s@%s:%d\n"								\
+		fd_log(level, "\t | tid:%-20s\t%s\tin %s@%s:%d\n"  \
 			  "\t%s|%*s" prefix ,  											\
 					__thn, fd_log_time(NULL, __buf, sizeof(__buf)), __PRETTY_FUNCTION__, __FILE__, __LINE__,\
 					(level < FULL)?"@":" ",level, ""); 							\
 		sSA_DUMP_NODE_SERV( sa, flags );										\
-		fd_log_debug(suffix "\n");											\
+		fd_log(level, suffix);                        \
 	}															\
 }
@@ -418,5 +423,5 @@
 #define TRACE_DEBUG_sSA(level, prefix, sa, flags, suffix )
 #define TRACE_DEBUG_ERROR(format,args... ) {	\
-	fd_log_debug(format "\n", ## args); 	\
+	fd_log(FD_LOG_ERROR, format, ## args); 	\
 }
 #endif /* STRIP_DEBUG_CODE */
@@ -1164,24 +1169,4 @@
 };
 
-/****
- Callbacks defined in libfdproto/dictionary_functions.c file -- see that file for usage. 
- */
-
-/* Convert an Address type AVP into a struct sockaddr_storage */
-int fd_dictfct_Address_encode(void * data, union avp_value * avp_value);
-int fd_dictfct_Address_interpret(union avp_value * avp_value, void * interpreted);
-char * fd_dictfct_Address_dump(union avp_value * avp_value);
-
-/* Display the content of an AVP of type UTF8String in the log file */
-char * fd_dictfct_UTF8String_dump(union avp_value * avp_value);
-
-/* For Time AVPs, map with time_t value directly */
-int fd_dictfct_Time_encode(void * data, union avp_value * avp_value);
-int fd_dictfct_Time_interpret(union avp_value * avp_value, void * interpreted);
-char * fd_dictfct_Time_dump(union avp_value * avp_value);
-
-
-
-/****/
 
 /***
@@ -1214,5 +1199,5 @@
  
 */
-
+	 
 /*
  ***************************************************************************
@@ -1816,7 +1801,7 @@
  *
  * RETURN VALUE:
- *  0      	: The session is created, the initial msg refcount is 1.
- *  EINVAL 	: A parameter is invalid.
- *  EALREADY	: A session with the same name already exists (returned in *session), the msg refcount is increased.
+ *  0      	: The session is created.
+ *  EINVAL 	: A parameter is invalid.
+ *  EALREADY	: A session with the same name already exists (returned in *session)
  *  ENOMEM	: Not enough memory to complete the operation
  */
@@ -2505,8 +2490,4 @@
 int fd_msg_sess_get(struct dictionary * dict, struct msg * msg, struct session ** session, int * isnew);
 
-/* This one is used by the libfdcore, you should use fd_msg_new_session rather than fd_sess_new, when possible */
-int fd_msg_sess_set(struct msg * msg, struct session * session);
-
-
 /***************************************/
 /*   Manage AVP values                 */
