diff -ur /usr/src/asterisk/channels/chan_h323.c ./chan_h323.c
--- /usr/src/asterisk/channels/chan_h323.c	2004-07-22 16:50:44.000000000 +0200
+++ ./chan_h323.c	2004-07-23 11:07:38.000000000 +0200
@@ -1446,7 +1446,7 @@
 	if (argc != 3) {
 		return RESULT_SHOWUSAGE;
 	}
-	h323_debug(1, atoi(argv[2]));
+	h323_trace(1, atoi(argv[2]));
 	ast_cli(fd, "H.323 trace set to level %s\n", argv[2]);
 	return RESULT_SUCCESS;
 }
@@ -1456,19 +1456,26 @@
 	if (argc != 3) {
 		return RESULT_SHOWUSAGE;
 	}
-	h323_debug(0,0);
+	h323_trace(0,0);
 	ast_cli(fd, "H.323 trace disabled\n");
 	return RESULT_SUCCESS;
 }
 
 static int h323_do_debug(int fd, int argc, char *argv[])
 {
-	if (argc != 2) {
-		return RESULT_SHOWUSAGE;
-	}
-	h323debug = 1;
-	ast_cli(fd, "H323 debug enabled\n");
-	return RESULT_SUCCESS;
+
+        if (argc == 2) {
+                h323debug = 1;
+                ast_cli(fd, "H323 deubg enabled\n");
+                return RESULT_SUCCESS;
+        } else if (argc == 3) {
+                h323_debug(1, atoi(argv[2]));
+                ast_cli(fd, "H.323 debug set to level %s\n", argv[2]);
+                return RESULT_SUCCESS;
+        } else {
+                return RESULT_SHOWUSAGE;
+        }
+
 }
 
 static int h323_no_debug(int fd, int argc, char *argv[])
@@ -1477,6 +1484,7 @@
 		return RESULT_SHOWUSAGE;
 	}
 	h323debug = 0;
+        h323_debug(0,0);
 	ast_cli(fd, "H323 Debug disabled\n");
 	return RESULT_SUCCESS;
 }
diff -ur /usr/src/asterisk/channels/h323/ast_h323.cpp ./h323/ast_h323.cpp
--- /usr/src/asterisk/channels/h323/ast_h323.cpp	2004-07-22 15:19:31.000000000 +0200
+++ ./h323/ast_h323.cpp	2004-07-22 16:48:02.000000000 +0200
@@ -844,7 +844,7 @@
 	delete localProcess;
 }
 
-void h323_debug(int flag, unsigned level)
+void h323_trace(int flag, unsigned level)
 {
 	if (flag) {
 		PTrace:: SetLevel(level); 
@@ -852,6 +852,17 @@
 		PTrace:: SetLevel(0); 
 	}
 }
+
+void h323_debug(int flag, unsigned level)
+{
+	if (flag) {
+		AstLog:: SetLevel(level); 
+	} else { 
+		AstLog:: SetLevel(0); 
+	}
+}
+
+
 	
 /** Installs the callback functions on behalf of the PBX application  */
 void h323_callback_register(setup_incoming_cb  	ifunc,
diff -ur /usr/src/asterisk/channels/h323/ast_h323.h ./h323/ast_h323.h
--- /usr/src/asterisk/channels/h323/ast_h323.h	2004-06-30 11:24:25.000000000 +0200
+++ ./h323/ast_h323.h	2004-07-22 16:03:00.000000000 +0200
@@ -280,6 +280,34 @@
      	WORD externalPort;               
 }; 
 
+
+/* ast_log-like debuging functions
+ * debug is activated throught the cli
+ * by default, trace level is 1 so that the only way
+ * to use it is AST_LOG(1, args)
+ * TODO: implement levels in h323 debugging ?
+ */
+
+static unsigned Ast_TraceLevelThreshold = 0;
+
+class AstLog : public PTrace {
+
+        public:
+                                
+        static BOOL CanTrace(unsigned level) { return level <= Ast_TraceLevelThreshold; }
+        static void SetLevel(unsigned level) { Ast_TraceLevelThreshold = level; }
+        
+};
+
+#define AST_LOG(level, args) \
+        if (!AstLog::CanTrace(level)) ; else \
+                AstLog::Begin(level, __FILE__, __LINE__) << args << AstLog::End
+
+#define AST_LOG_IF(level, cond, args) \
+        if (!(AstLog::CanTrace(level)  && (cond))) ; else \
+                AstLog::Begin(level, __FILE__, __LINE__) << args << PTrace::End
+                                                
+
 /**
  * The MyProcess is a necessary descendant PProcess class so that the H323EndPoint 
  * objected to be created from within that class. (Who owns main() problem). 
Les fichiers binaires /usr/src/asterisk/channels/h323/ast_h323.o et ./h323/ast_h323.o sont différents.
diff -ur /usr/src/asterisk/channels/h323/chan_h323.h ./h323/chan_h323.h
--- /usr/src/asterisk/channels/h323/chan_h323.h	2004-07-22 15:19:31.000000000 +0200
+++ ./h323/chan_h323.h	2004-07-22 15:27:27.000000000 +0200
@@ -171,6 +171,7 @@
 	int  h323_end_point_exist(void);
     
 	void h323_debug(int, unsigned);
+        void h323_trace(int, unsigned);
 
 	/* callback function handler*/
 	void h323_callback_register(setup_incoming_cb,  

