diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/daemon/common/commonComplexOptions.ml ./src/daemon/common/commonComplexOptions.ml
--- ./src/daemon/common/commonComplexOptions.ml	2004-05-03 10:22:24.000000000 +0200
+++ ./src/daemon/common/commonComplexOptions.ml	2004-05-31 18:00:43.000000000 +0200
@@ -110,9 +110,9 @@
             with _ -> ());
           set_file_state file file_state;       
           (match file_state with
-              FileDownloading -> lprintf "New downloading file\n";
-            | FileDownloaded -> lprintf "New downloaded file\n";
-            | _ -> lprintf "..........\n"
+              FileDownloading -> BLOG DEBUG : "New downloading file\n" ELOG; ();
+            | FileDownloaded -> BLOG DEBUG : "New downloaded file\n" ELOG; ();
+            | _ -> BLOG DEBUG : "..........\n" ELOG; ()
           );
           
           (try
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/daemon/common/commonMultimedia.ml ./src/daemon/common/commonMultimedia.ml
--- ./src/daemon/common/commonMultimedia.ml	2004-03-18 00:42:32.000000000 +0100
+++ ./src/daemon/common/commonMultimedia.ml	2004-05-31 18:00:46.000000000 +0200
@@ -231,7 +231,7 @@
   try
     let tag = Mp3tag.Id3v1.read filename in
     let info = Mp3tag.info filename in
-    lprintf "MP3 INFO FOUND\n"; 
+    BLOG INFO : "MP3 INFO FOUND\n" ELOG;
     raise (FormatFound (MP3 (tag, info)))
   with
   | FormatFound _ as e -> raise e
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/daemon/common/commonNetwork.ml ./src/daemon/common/commonNetwork.ml
--- ./src/daemon/common/commonNetwork.ml	2004-04-16 19:14:53.000000000 +0200
+++ ./src/daemon/common/commonNetwork.ml	2004-05-31 18:00:43.000000000 +0200
@@ -27,7 +27,7 @@
 let ni n m = 
   let s = Printf.sprintf "Network.%s not implemented by %s" 
       m n in
-  lprintf "%s\n" s; 
+    BLOG DEBUG : "%s\n" s ELOG;
   s
   
 let fni n m =  failwith (ni n m)
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/daemon/common/commonOptions.ml ./src/daemon/common/commonOptions.ml
--- ./src/daemon/common/commonOptions.ml	2004-05-04 10:58:48.000000000 +0200
+++ ./src/daemon/common/commonOptions.ml	2004-05-31 18:00:43.000000000 +0200
@@ -1139,7 +1139,8 @@
   string_option ""  
 
 let verbosity = define_expert_option current_section ["verbosity"] 
-  "A space-separated list of keywords. Each keyword triggers
+  "This option works only if verbosity_level = debug
+  A space-separated list of keywords. Each keyword triggers
   printing information on the corresponding messages:
   mc : debug client messages
   mct : debug emule clients tags
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/daemon/common/commonShared.ml ./src/daemon/common/commonShared.ml
--- ./src/daemon/common/commonShared.ml	2004-05-03 10:22:25.000000000 +0200
+++ ./src/daemon/common/commonShared.ml	2004-05-31 18:00:43.000000000 +0200
@@ -71,7 +71,7 @@
 let ni n m = 
   let s = Printf.sprintf "Shared.%s not implemented by %s" 
       m n.network_name in
-  lprintf "%s\n" s;
+    BLOG DEBUG : "%s\n" s ELOG;
   s
   
 let fni  n m =  failwith (ni n m)
@@ -236,7 +236,7 @@
   if can_share dirname then
     try
       let files = Unix2.list_directory full_dir in
-      lprintf "Sharing sub-directory %s\n" full_dir; 
+      BLOG DEBUG : "Sharing sub-directory %s\n" (full_dir) ELOG;
       List.iter (fun file ->
           if file <> "" && file.[0] <> '.' then
             let full_name = Filename.concat full_dir file in
@@ -284,8 +284,9 @@
     
 let shared_add_directory shared_dir =
   if shared_dir.shdir_dirname <> "" then begin
-      lprintf "SHARING %s PRIO %d\n" shared_dir.shdir_dirname
-        shared_dir.shdir_priority;
+      BLOG DEBUG : "SHARING %s PRIO %d\n"
+       (shared_dir.shdir_dirname)
+       (shared_dir.shdir_priority) ELOG;
       shared_add_directory shared_dir ""
     end
 
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/daemon/common/commonSwarming.ml ./src/daemon/common/commonSwarming.ml
--- ./src/daemon/common/commonSwarming.ml	2004-05-03 10:22:25.000000000 +0200
+++ ./src/daemon/common/commonSwarming.ml	2004-05-31 18:00:46.000000000 +0200
@@ -480,8 +480,8 @@
               t.t_blocks.(i) <- VerifiedBlock;
             
             end else begin
-              lprintf "VERIFICATION OF BLOC %d OF %s FAILED\n"
-                i (file_best_name t.t_file);
+              BLOG WARN : "VERIFICATION OF BLOC %d OF %s FAILED\n"
+                (i) (file_best_name t.t_file) ELOG;
               t.t_ncomplete_blocks <- t.t_ncomplete_blocks - 1;
               
               match t.t_blocks.(i) with
@@ -1761,7 +1761,7 @@
 let value_to_swarmer t assocs = 
   let get_value name conv = conv (List.assoc name assocs) in
   
-  lprintf "Setting bitmap\n";
+  BLOG DEBUG : "Setting bitmap\n" ELOG;
   (try
       
       let set_bitmap =
@@ -1786,7 +1786,7 @@
           (Printexc2.to_string e); 
   );
   
-  lprintf "Loading present...\n";
+  BLOG DEBUG : "Loading present...\n" ELOG;
   let present = try 
       let present = 
         (get_value "file_present_chunks" 
@@ -1795,42 +1795,42 @@
       set_present t present;
       present
     with e ->
-        lprintf "Exception %s while set present\n"
-          (Printexc2.to_string e);         
+        BLOG DEBUG : "Exception %s while set present\n"
+          (Printexc2.to_string e) ELOG;
         []
   in
-  lprintf "Downloaded after present %Ld\n" (downloaded t);
+  BLOG DEBUG : "Downloaded after present %Ld\n" (downloaded t) ELOG;
   
-  lprintf "Loading absent...\n";
+  BLOG DEBUG : "Loading absent...\n" ELOG;
   (try 
       set_absent t 
         (get_value "file_absent_chunks" 
           (value_to_list value_to_int64_pair));
     with e ->
-        lprintf "Exception %s while set absent\n"
-          (Printexc2.to_string e);         
+        BLOG DEBUG : "Exception %s while set absent\n"
+          (Printexc2.to_string e) ELOG; ();
   );
-  lprintf "Downloaded after absent %Ld\n" (downloaded t);
+  BLOG DEBUG : "Downloaded after absent %Ld\n" (downloaded t) ELOG;
   
   (try 
       let d = get_value "file_downloaded" value_to_int64 in
       
-      if d <> downloaded t then begin
-          lprintf "ERROR: CommonSwarming: stored downloaded value not restored  !!! (%Ld/%Ld)\n" (downloaded t) d;
-          lprintf "ERROR: CommonSwarming: present:\n";
+      BLOG DEBUG (d <> downloaded t) #
+          begin
+          BLOG DEBUG : "ERROR: CommonSwarming: stored downloaded value not restored  !!! (%Ld/%Ld)\n" (downloaded t) (d) ELOG;
+          BLOG DEBUG : "ERROR: CommonSwarming: present:\n" ELOG;
           List.iter (fun (x,y) ->
-              lprintf "     (%Ld,%Ld);\n" x y  
+              BLOG DEBUG : "     (%Ld,%Ld);\n" (x) (y) ELOG
           ) present;
           
           let p = present_chunks t in
-          lprintf "ERROR: CommonSwarming: present now:\n";
+          BLOG DEBUG : "ERROR: CommonSwarming: present now:\n" ELOG;
           List.iter (fun (x,y) ->
-              lprintf "     (%Ld,%Ld);\n" x y  
+              BLOG DEBUG : "     (%Ld,%Ld);\n" (x) (y) ELOG
           ) p;
-          
-          
 (*          exit 2 *)
-        end
+          end
+      ELOG
           
     with e -> ());
   
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/daemon/common/commonUploads.ml ./src/daemon/common/commonUploads.ml
--- ./src/daemon/common/commonUploads.ml	2004-05-03 10:22:25.000000000 +0200
+++ ./src/daemon/common/commonUploads.ml	2004-05-31 18:00:43.000000000 +0200
@@ -810,7 +810,7 @@
     
 let add_pending_slot c =
   if client_has_a_slot c then begin
-      lprintf "Avoided inserting an uploader in pending slots!\n";
+      BLOG DEBUG : "Avoided inserting an uploader in pending slots!\n" ELOG; ();
     end 
   else 
   if not (Intmap.mem (client_num c) !pending_slots_map) then
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/daemon/common/commonWeb.ml ./src/daemon/common/commonWeb.ml
--- ./src/daemon/common/commonWeb.ml	2004-05-03 10:22:25.000000000 +0200
+++ ./src/daemon/common/commonWeb.ml	2004-05-31 18:00:46.000000000 +0200
@@ -58,7 +58,7 @@
   
   
 let load_url kind url =
-  lprintf "QUERY URL %s\n" url; 
+  BLOG INFO : "QUERY URL %s\n" (url) ELOG;
   let f = 
     try 
       List.assoc kind !file_kinds 
@@ -204,7 +204,7 @@
   let packet = gen_redirector_packet () in
   Ip.async_ip name (fun ip ->
       try
-        lprintf "connecting to redirector\n";
+        BLOG INFO : "connecting to redirector\n" ELOG;
         let token = create_token unlimited_connection_manager in
         let sock = TcpBufferedSocket.connect token "connect redirector"
             (Ip.to_inet_addr ip) port            
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/daemon/driver/driverInterface.ml ./src/daemon/driver/driverInterface.ml
--- ./src/daemon/driver/driverInterface.ml	2004-05-03 10:22:25.000000000 +0200
+++ ./src/daemon/driver/driverInterface.ml	2004-05-31 18:00:46.000000000 +0200
@@ -498,8 +498,7 @@
           (to_gui_last_opcode + 1) version;
         gui.gui_proto_from_gui_version <- Array.create 
           (from_gui_last_opcode + 1) version;
-        lprintf "Using protocol %d for communications with the GUI\n" 
-          version    
+        BLOG INFO : "Using protocol %d for communications with the GUI\n" version ELOG
     
     | P.GuiExtensions list ->
         List.iter (fun (ext, bool) ->
@@ -1021,7 +1020,7 @@
   match event with
     TcpServerSocket.CONNECTION (s, Unix.ADDR_INET (from_ip, from_port)) ->
       let from_ip = Ip.of_inet_addr from_ip in
-      lprintf "CONNECTION FROM GUI\n"; 
+      BLOG INFO : "CONNECTION FROM GUI\n" ELOG;
       if Ip.matches from_ip !!allowed_ips then 
         
         let module P = GuiProto in
@@ -1046,7 +1045,7 @@
         TcpBufferedSocket.set_closer sock (gui_closed gui);
         TcpBufferedSocket.set_handler sock TcpBufferedSocket.BUFFER_OVERFLOW
           (fun _ -> 
-            lprintf "BUFFER OVERFLOW\n"; 
+            BLOG DEBUG : "BUFFER OVERFLOW\n" ELOG;
             close sock Closed_for_overflow);
         (* sort GUIs in increasing order of their num *)
         
@@ -1061,7 +1060,7 @@
   match event with
     TcpServerSocket.CONNECTION (s, Unix.ADDR_INET (from_ip, from_port)) ->
       let from_ip = Ip.of_inet_addr from_ip in
-      lprintf "CONNECTION FROM GUI\n"; 
+      BLOG INFO : "CONNECTION FROM GUI\n" ELOG;
       if Ip.matches from_ip !!allowed_ips then 
         
         let module P = GuiProto in
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/daemon/driver/driverMain.ml ./src/daemon/driver/driverMain.ml
--- ./src/daemon/driver/driverMain.ml	2004-05-04 10:59:03.000000000 +0200
+++ ./src/daemon/driver/driverMain.ml	2004-05-31 18:00:41.000000000 +0200
@@ -96,7 +96,7 @@
           chat_port DriverControlers.chat_handler);  
       try
         CommonChat.send_hello ()
-      with _ -> lprintf (_b "CommonChat.send_hello failed"); 
+      with _ -> lprintf (_b "CommonChat.send_hello failed\n"); 
     end;
   
   gui_server_sock := find_port "gui server"  !!gui_bind_addr
@@ -446,6 +446,9 @@
   lprintf (_b "Or with browser: http://%s:%d\n") 
 	(if !!http_bind_addr = Ip.any then "127.0.0.1" 
 		else Ip.to_string !!http_bind_addr)  !!http_port; 
+  lprintf (_b "Or with WAP: http://%s:%d/wap.wml\n") 
+	(if !!http_bind_addr = Ip.any then "127.0.0.1" 
+		else Ip.to_string !!http_bind_addr)  !!http_port; 
   
   lprint_string (DriverControlers.text_of_html !!motd_html);
   lprint_newline ();
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/gtk/gui/gui_com.ml ./src/gtk/gui/gui_com.ml
--- ./src/gtk/gui/gui_com.ml	2004-03-07 10:37:37.000000000 +0100
+++ ./src/gtk/gui/gui_com.ml	2004-05-31 18:00:43.000000000 +0200
@@ -124,7 +124,7 @@
     TcpBufferedSocket.set_max_output_buffer sock !!O.interface_buffer;
     TcpBufferedSocket.set_handler sock TcpBufferedSocket.BUFFER_OVERFLOW
     (fun _ -> 
-        lprintf "BUFFER OVERFLOW"; lprint_newline ();
+        BLOG DEBUG : "BUFFER OVERFLOW\n" ELOG;
         TcpBufferedSocket.close sock Closed_for_overflow);
     TcpBufferedSocket.set_reader sock (
       GuiDecoding.gui_cut_messages
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/gtk/newgui/gui_com.ml ./src/gtk/newgui/gui_com.ml
--- ./src/gtk/newgui/gui_com.ml	2004-03-18 00:42:32.000000000 +0100
+++ ./src/gtk/newgui/gui_com.ml	2004-05-31 18:00:43.000000000 +0200
@@ -129,7 +129,7 @@
     TcpBufferedSocket.set_max_input_buffer sock !!O.interface_buffer;
     TcpBufferedSocket.set_handler sock TcpBufferedSocket.BUFFER_OVERFLOW
     (fun _ -> 
-        lprintf "BUFFER OVERFLOW\n"; 
+        BLOG DEBUG : "BUFFER OVERFLOW\n" ELOG;
         TcpBufferedSocket.close sock Closed_for_overflow);
     TcpBufferedSocket.set_reader sock (
       GuiDecoding.gui_cut_messages
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/bittorrent/bTTracker.ml ./src/networks/bittorrent/bTTracker.ml
--- ./src/networks/bittorrent/bTTracker.ml	2004-03-07 10:34:25.000000000 +0100
+++ ./src/networks/bittorrent/bTTracker.ml	2004-05-31 18:00:52.000000000 +0200
@@ -58,7 +58,7 @@
   *)
   
 let decode_torrent s =
-  lprintf ".torrent file loaded\n";
+  BLOG INFO : ".torrent file loaded\n" ELOG;
 (*            lprintf "Loaded: %s\n" (String.escaped s); *)
   let v = Bencode.decode s in
 (*            lprintf "Decoded file: %s\n" (Bencode.print v);  *)
@@ -98,9 +98,11 @@
                     length_set := true
                 
                 | String key, _ -> 
-                    lprintf "other field [%s] in files\n" key
+                    BLOG INFO : "other field [%s] in files\n" (key) ELOG;
+		    ()
                 | _ -> 
-                    lprintf "other field in files\n"
+                    BLOG INFO : "other field in files\n" ELOG;
+		    ()
             ) list;
             
             assert (!length_set);
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/donkey/donkeyChunks.ml ./src/networks/donkey/donkeyChunks.ml
--- ./src/networks/donkey/donkeyChunks.ml	2004-05-03 10:22:25.000000000 +0200
+++ ./src/networks/donkey/donkeyChunks.ml	2004-05-31 18:00:52.000000000 +0200
@@ -358,8 +358,8 @@
                               other_swarmer in
                           if other_bitmap.[i] = '3' then
                             begin
-                              lprintf "Should copy chunk %d [%Ld:%Ld] from %s to %s\n" i chunk_pos chunk_size
-                                (file_best_name other_file) (file_best_name file);
+                              BLOG DEBUG : "Should copy chunk %d [%Ld:%Ld] from %s to %s\n" (i) (chunk_pos) (chunk_size)
+                                (file_best_name other_file) (file_best_name file) ELOG;
                               
                               if not (List.memq file !modified_files) then
                                 modified_files := file :: !modified_files;
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/donkey/donkeyClient.ml ./src/networks/donkey/donkeyClient.ml
--- ./src/networks/donkey/donkeyClient.ml	2004-05-05 22:56:49.000000000 +0200
+++ ./src/networks/donkey/donkeyClient.ml	2004-05-31 18:00:52.000000000 +0200
@@ -71,10 +71,9 @@
   if not (Hashtbl.mem banned_ips ip) then
     let module M = DonkeyProtoClient in
     
-    if !verbose then begin
-        lprintf "client %s(%s) %s, it has been banned\n" msg
-          c.client_name (brand_to_string c.client_brand);
-      end;
+    BLOG DEBUG (!verbose) : "client %s(%s) %s, it has been banned\n"
+        (msg) (c.client_name) (brand_to_string c.client_brand)
+    ELOG;
     
     count_banned c;
     c.client_banned <- true;
@@ -107,10 +106,9 @@
               ban_client c sock "is connecting too fast";
               raise Exit;
             end;
-          if !verbose then begin
-              lprintf "uploader %s(%s) has been warned\n" 
-                c.client_name (brand_to_string c.client_brand);
-            end;
+          BLOG DEBUG (!verbose) : "uploader %s(%s) has been warned\n" 
+                (c.client_name) (brand_to_string c.client_brand)
+          ELOG;
           if !!send_warning_messages then
             client_send c ( M.SayReq  (
                 "[AUTOMATED WARNING] Your client is connecting too fast, it will get banned"))
@@ -141,10 +139,9 @@
           let module Q = M.AvailableSlot in
           M.AvailableSlotReq Q.t);
         
-        if !verbose then begin
-            lprintf "New uploader %s: brand %s\n" 
-              c.client_name (brand_to_string c.client_brand);
-          end;
+        BLOG DEBUG (!verbose) : "New uploader %s: brand %s\n"
+          (c.client_name) (brand_to_string c.client_brand)
+        ELOG;
         
     )  
   in
@@ -337,9 +334,8 @@
                       | Reliability_suspicious _ -> ()
                   ) group.group;
                   if !list <> [] then begin
-                      if !verbose_sources then begin
-                          lprintf "Send %d sources from file groups to mldonkey peer\n" (List.length !list); 
-                        end;
+                      BLOG DEBUG (!verbose_sources) : "Send %d sources from file groups to mldonkey peer\n"
+		       (List.length !list) ELOG;
                       let msg = 
                         let module Q = DonkeyProtoClient.Sources in
                         DonkeyProtoClient.SourcesReq {
@@ -360,8 +356,7 @@
               
               UdpClientMap.iter (fun _ uc ->
                   if uc.udp_client_can_receive then begin
-                      if !verbose_sources then
-                        lprintf "Send new source to file groups UDP peers\n"; 
+                      BLOG DEBUG (!verbose_sources) : "Send new source to file groups UDP peers\n" ELOG;
                       udp_client_send uc (
                         Udp.QueryLocationReplyUdpReq (
                           let module Q = DonkeyProtoServer.QueryLocationReply in
@@ -587,8 +582,8 @@
               c.client_emule_proto.emule_secident <- i land 0x3)          
       
       | s -> 
-          if !verbose_msg_clients then
-            lprintf "Unknown Emule tag: [%s]\n" (String.escaped s)
+          BLOG DEBUG (!verbose_msg_clients) : "Unknown Emule tag: [%s]\n" (String.escaped s) ELOG;
+	  ()
   ) tags
 
 let query_id ip port id =
@@ -668,8 +663,7 @@
   !files;
   if !nqueries > 0 then
     c.client_last_filereqs <- last_time ();
-  if !verbose then begin
-      lprintf "sent %d/%d file queries\n" !nqueries !nall_queries;
+  BLOG DEBUG (!verbose) : "sent %d/%d file queries\n" (!nqueries) (!nall_queries) ELOG;
     end
 *)
 
@@ -899,18 +893,18 @@
       let module CI = M.EmuleClientInfo in
       
       update_emule_proto_from_tags c t.CI.tags;
-      
-      if !verbose_msg_clienttags then begin
-          lprintf "Message from client[%d] %s(%s)%s\n" (client_num c)
-          c.client_name (brand_to_string c.client_brand)
-          (match c.client_kind with
+
+      BLOG DEBUG (!verbose_msg_clienttags) : "Message from client[%d] %s(%s)%s\ntags: %s\n"
+         (client_num c)
+         (c.client_name)
+         (brand_to_string c.client_brand)
+         (match c.client_kind with
               Indirect_address _ | Invalid_address _ -> ""
             | Direct_address (ip,port) ->
                 Printf.sprintf  " [%s:%d]" (Ip.to_string ip) port;
-          );
-          let xx = string_of_tags_list t.CI.tags in
-          lprintf "tags: %s\n" xx;
-        end
+         )
+	 (string_of_tags_list t.CI.tags)
+      ELOG
 
 (*   lprintf "Emule Extended Protocol activated\n"; *)
   
@@ -1065,10 +1059,9 @@
           client_enter_upload_queue cc
         end else *)
       CommonUploads.add_pending_slot (as_client c);
-      if !verbose then begin
-          lprintf "(uploader %s: brand %s, couldn't get a slot)\n" 
-            c.client_name (brand_to_string c.client_brand);
-        end;
+      BLOG DEBUG (!verbose) : "(uploader %s: brand %s, couldn't get a slot)\n"
+            (c.client_name) (brand_to_string c.client_brand)
+      ELOG;
 (*      end *)
   
   | M.CloseSlotReq _ ->
@@ -1088,9 +1081,7 @@
         match c.client_file_queue with
           [] -> ()
         | _ -> 
-            if !verbose_download then begin
-                lprintf "CloseSlotReq\n"; 
-              end;
+            BLOG DEBUG (!verbose_download) : "CloseSlotReq\n" ELOG;
             DonkeyOneFile.request_slot c;
             set_rtimeout sock !!queued_timeout;
       end
@@ -1174,12 +1165,11 @@
         let file = find_file t.Q.md4 in
         
         let module Q = M.QueryChunkMd4Reply in
-        if !verbose then begin
-            lprintf "MD4 FOR CHUNKS RECEIVED\n"; 
-          end;
+        BLOG DEBUG (!verbose) : "MD4 FOR CHUNKS RECEIVED\n" ELOG;
         
         if file.file_md4s <> [||] then begin
-            lprintf "[WARNING] Discarding Chunks Md4: already here\n";
+            BLOG WARN : "[WARNING] Discarding Chunks Md4: already here\n" ELOG;
+	    ();
           end else
         if file.file_nchunks = 1 then begin
             lprintf "[ERROR]: one chunk file without md4\n"; 
@@ -1271,12 +1261,12 @@
             DonkeyOneFile.block_received c comp.comp_md4
               comp.comp_pos s 0 (String.length s)
           else
-            lprintf "ERROR: No Zlib to uncompress packet";
+            BLOG DEBUG : "ERROR: No Zlib to uncompress packet" ELOG;
           
           c.client_comp <- None;
         end else
       if comp.comp_len > comp.comp_total then begin
-          lprintf "ERROR: more data than compressed!!!\n";
+          BLOG DEBUG : "ERROR: more data than compressed!!!\n" ELOG;
           c.client_comp <- None;
         end
   
@@ -1285,7 +1275,7 @@
       set_lifetime sock active_lifetime;      
       if !!reliable_sources && 
         client_reliability c = Reliability_suspicious 0 then begin
-          lprintf "Receiving data from unreliable client, disconnect\n";
+          BLOG DEBUG : "Receiving data from unreliable client, disconnect\n" ELOG;
           corruption_warning c;
           disconnect_client c (Closed_for_error "Unreliable Source");
           raise Not_found
@@ -1298,7 +1288,7 @@
       let end_pos = t.Q.end_pos in
       let len = Int64.sub end_pos begin_pos in
       if Int64.to_int len <> t.Q.bloc_len then begin
-          lprintf "%d: inconsistent packet sizes\n" (client_num c);
+          BLOG DEBUG : "%d: inconsistent packet sizes\n" (client_num c) ELOG;
           raise Not_found
         end;
       
@@ -1388,9 +1378,7 @@
               lprintf "** Dropped %d sources for %s **\n" (List.length t.Q.sources) (file_best_name file);
               
 end else *)
-          if !verbose_location then begin
-              lprintf "Client: Received %d sources for %s\n" (Array.length t.Q.sources) (file_best_name file);
-            end;
+          BLOG DEBUG (!verbose_location) : "Client: Received %d sources for %s\n" (Array.length t.Q.sources) (file_best_name file) ELOG;
           Array.iter (fun s ->
               try
               let addr = 
@@ -1508,10 +1496,7 @@
   | M.QueryBlocReq t when !CommonUploads.has_upload = 0 &&
     client_has_a_slot (as_client c) ->
       
-      if !verbose then begin
-          lprintf "uploader %s(%s) ask for block\n" c.client_name
-            (brand_to_string c.client_brand); 
-        end;
+      BLOG DEBUG (!verbose) : "uploader %s(%s) ask for block\n" (c.client_name) (brand_to_string c.client_brand) ELOG;
 
       let module Q = M.QueryBloc in
       let file = find_file  t.Q.md4 in
@@ -1873,8 +1858,9 @@
       None
   
   | _ -> 
-      lprintf "BAD MESSAGE FROM CONNECTING CLIENT\n"; 
-      M.print m; lprintf "\n";
+      BLOG DEBUG (!verbose_unknown_messages) #
+      BLOG DEBUG : "BAD MESSAGE FROM CONNECTING CLIENT\n" ELOG;
+      M.print m; lprintf "\n" ELOG;
       close sock (Closed_for_error "bad connecting message");
       raise Not_found
       
@@ -1985,9 +1971,7 @@
     let file = find_file t.Q.md4 in
     let nlocs = List.length t.Q.locs in
     
-    if !verbose_location then begin
-        lprintf "Server: Received %d sources for %s\n" nlocs (file_best_name file);
-      end;
+    BLOG DEBUG (!verbose_location) : "Server: Received %d sources for %s\n" (nlocs) (file_best_name file) ELOG;
     
     s.server_score <- s.server_score + 3;
     
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/donkey/donkeyComplexOptions.ml ./src/networks/donkey/donkeyComplexOptions.ml
--- ./src/networks/donkey/donkeyComplexOptions.ml	2004-05-04 10:59:04.000000000 +0200
+++ ./src/networks/donkey/donkeyComplexOptions.ml	2004-05-31 18:00:46.000000000 +0200
@@ -584,7 +584,7 @@
   
       
 let load _ =
-  lprintf "LOADING SHARED FILES AND SOURCES\n"; 
+  BLOG DEBUG : "LOADING SHARED FILES AND SOURCES\n" ELOG;
   (try
       Options.load shared_files_ini;
       Options.load stats_ini;
@@ -637,8 +637,7 @@
 let diff_time = ref 0
 
 let save _ =
-  lprintf "SAVING SHARED FILES AND SOURCES";
-  CommonGlobals.print_localtime ();
+  BLOG INFO : "SAVING SHARED FILES AND SOURCES" ELOG;
   Options.save_with_help shared_files_ini;
   guptime =:= !!guptime + (last_time () - start_time) - !diff_time;
   diff_time := (last_time () - start_time);
@@ -649,7 +648,7 @@
   let cleaner = DonkeySources.attach_sources_to_file file_sources_section in
   Options.save_with_help file_sources_ini;
   cleaner ();
-  lprintf "SAVED\n"; 
+  BLOG INFO : "SAVED\n" ELOG;
   create_online_sig ()
     
 let guptime () = !!guptime - !diff_time
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/donkey/donkeyFiles.ml ./src/networks/donkey/donkeyFiles.ml
--- ./src/networks/donkey/donkeyFiles.ml	2004-05-03 10:22:25.000000000 +0200
+++ ./src/networks/donkey/donkeyFiles.ml	2004-05-31 18:00:41.000000000 +0200
@@ -78,11 +78,9 @@
 (*      let len_int = Int32.to_int len in *)
       CommonUploads.consume_bandwidth len_int;
       try
-        if !verbose then begin
-            lprintf "send_small_block(%s-%s) %Ld %d\n"
-              c.client_name (brand_to_string c.client_brand)
-            (begin_pos) (len_int);
-          end;
+	BLOG DEBUG (!verbose) : "send_small_block(%s-%s) %Ld %d\n"
+              (c.client_name) (brand_to_string c.client_brand) (begin_pos) (len_int)
+        ELOG;
         
         let msg =  
           (
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/donkey/donkeyGlobals.ml ./src/networks/donkey/donkeyGlobals.ml
--- ./src/networks/donkey/donkeyGlobals.ml	2004-05-05 22:55:37.000000000 +0200
+++ ./src/networks/donkey/donkeyGlobals.ml	2004-05-31 18:00:41.000000000 +0200
@@ -204,9 +204,7 @@
         }  in
       HS.add sources_by_address s;
       incr stats_sources;
-      if !verbose_sources then begin
-          lprintf "Source %d added\n" n; 
-        end;
+      BLOG DEBUG (!verbose_sources) : "Source %d added\n" n ELOG;
       s
         *)
 
@@ -330,7 +328,7 @@
 let new_shared_files = ref [] 
         
 let new_file file_state file_name md4 file_size writable =
-  lprintf "NEW FILE TO DOWNLOAD ??????????? %s\n" file_name;
+  BLOG DEBUG : "NEW FILE TO DOWNLOAD ??????????? %s\n" (file_name) ELOG;
   try
     find_file md4 
   with _ ->
@@ -474,8 +472,7 @@
     (match Ip_set.match_ip !Ip_set.bl ip with
         None -> false
       | Some br ->
-          if !verbose_connect then
-            lprintf "%s:%d blocked: %s\n" (Ip.to_string ip) port br.Ip_set.blocking_description;
+          BLOG DEBUG (!verbose_connect) : "%s:%d blocked: %s\n" (Ip.to_string ip) (port) (br.Ip_set.blocking_description) ELOG;
           true))
   
 let new_server ip port score = 
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/donkey/donkeyInteractive.ml ./src/networks/donkey/donkeyInteractive.ml
--- ./src/networks/donkey/donkeyInteractive.ml	2004-05-04 10:59:05.000000000 +0200
+++ ./src/networks/donkey/donkeyInteractive.ml	2004-05-31 18:00:43.000000000 +0200
@@ -99,15 +99,14 @@
     ) ss;
     List.length ss
   with e ->
-      lprintf "Exception %s while loading %s\n" (Printexc2.to_string e)
-      filename;
+      BLOG WARN : "Exception %s while loading %s\n" (Printexc2.to_string e) (filename) ELOG; ();
       0
 
 let already_done = Failure "File already downloaded (use 'force_download' if necessary)"
       
 let really_query_download filenames size md4 location old_file absents =
   
-  lprintf "really_query_download..................... \n";
+  BLOG DEBUG : "really_query_download..................... \n" ELOG;
   begin
     try
       let file = Hashtbl.find files_by_md4 md4 in
@@ -128,15 +127,12 @@
         if Sys.file_exists filename && not (
             Unix32.file_exists temp_file) then
           (try 
-              if !verbose then begin
-                  lprintf "Renaming from %s to %s\n" filename
-                    temp_file; 
-                end;
+              BLOG DEBUG (!verbose) : "Renaming from %s to %s\n" (filename) (temp_file) ELOG; 
               Unix2.rename filename temp_file;
               Unix.chmod temp_file 0o644;
               with e -> 
-                lprintf "Could not rename %s to %s: exception %s\n"
-                  filename temp_file (Printexc2.to_string e);
+                BLOG WARN : "Could not rename %s to %s: exception %s\n"
+		(filename) (temp_file) (Printexc2.to_string e) ELOG; ();
                  );        
   end;
   
@@ -258,8 +254,7 @@
     let t = P.read s in
     t.P.client_tags, t.P.option_tags
   with e ->
-      lprintf "Exception %s while loading %s\n" (Printexc2.to_string e)
-      filename;
+      BLOG WARN : "Exception %s while loading %s\n" (Printexc2.to_string e) (filename) ELOG;
       [], []
       
 let import_temp temp_dir =  
@@ -312,8 +307,7 @@
       | { tag_name = "temp"; tag_value = String s } ->
           if Sys.file_exists s then (* be careful on that *)
             temp_dir := s
-          else (lprintf "Bad temp directory, using default\n";
-              )
+          else (BLOG WARN : "Bad temp directory, using default\n" ELOG; ())
       | _ -> ()
   ) ot;
 
@@ -791,7 +785,7 @@
       
       if not (List.mem file.file_md4 !!old_files) then
         old_files =:= file.file_md4 :: !!old_files;
-      lprintf "REMEMBER SHARE FILE INFO %s\n" new_name; 
+      BLOG DEBUG : "REMEMBER SHARE FILE INFO %s\n" (new_name) ELOG; 
       
 (**************************************************************
 
@@ -878,7 +872,7 @@
           } in
         v
       with e ->
-          lprintf "Exception %s in op_file_info\n" (Printexc2.to_string e);
+          BLOG DEBUG : "Exception %s in op_file_info\n" (Printexc2.to_string e) ELOG;
           raise e
           
   )
@@ -1066,7 +1060,7 @@
       force_check_server_connections true);
 
   network.op_network_recover_temp <- (fun _ ->
-      lprintf "op_network_recover_temp ++++++++++++++++++++++++++\n";
+      BLOG DEBUG : "op_network_recover_temp ++++++++++++++++++++++++++\n" ELOG;
       let files = Unix2.list_directory !!temp_directory in
       List.iter (fun filename ->
 	if String.length filename = 32 then
@@ -1086,8 +1080,7 @@
                         
                   recover_md4s md4
           with e ->
-            lprintf "exception %s in recover_temp\n"
-            (Printexc2.to_string e); 
+            BLOG WARN : "exception %s in recover_temp\n" (Printexc2.to_string e) ELOG; ();
       ) files
   );
   
@@ -1114,23 +1107,18 @@
       | Some files -> 
           List2.tail_map (fun r -> "", as_result r.result_result) files);
   client_ops.op_client_browse <- (fun c immediate ->
-      lprintf "*************** should browse  ***********\n"; 
+      BLOG DEBUG : "*************** should browse  ***********\n" ELOG;
       match c.client_source.DonkeySources.source_sock with
       | Connection sock    ->
-(*
-      lprintf "****************************************";
-      lprint_newline ();
-      lprintf "       ASK VIEW FILES         ";
-lprint_newline ();
-  *)
+          BLOG DEBUG : "****************************************\n" ELOG;
+          BLOG DEBUG : "       ASK VIEW FILES         \n" ELOG;
           client_send c (
             let module M = DonkeyProtoClient in
             let module C = M.ViewFiles in
             M.ViewFilesReq C.t);          
       | NoConnection -> 
-          lprintf "****************************************\n";
-          lprintf "       TRYING TO CONTACT FRIEND         \n";
-          
+          BLOG DEBUG : "****************************************\n" ELOG;
+          BLOG DEBUG : "       TRYING TO CONTACT FRIEND         \n" ELOG;
           reconnect_client c
       | _ -> ()
   );
@@ -1339,18 +1327,18 @@
 
 let _ =
   CommonWeb.add_web_kind "server.met" (fun filename ->
-      lprintf "FILE LOADED\n"; 
+      BLOG DEBUG : "FILE LOADED\n" ELOG;
       let n = load_server_met filename in
-      lprintf "%d SERVERS ADDED" n; lprint_newline ();    
+      BLOG INFO : "%d SERVERS ADDED\n" n ELOG;
   );
   CommonWeb.add_web_kind "servers.met" (fun filename ->
-      lprintf "FILE LOADED\n"; 
+      BLOG DEBUG : "FILE LOADED\n" ELOG;
       let n = load_server_met filename in
-      lprintf "%d SERVERS ADDED\n" n; 
+      BLOG INFO : "%d SERVERS ADDED\n" n ELOG;
   );
   CommonWeb.add_web_kind "comments.met" (fun filename ->
       DonkeyIndexer.load_comments filename;
-      lprintf "COMMENTS ADDED\n"; 
+      BLOG DEBUG : "COMMENTS ADDED\n" ELOG;
   );
   
   
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/donkey/donkeyMain.ml ./src/networks/donkey/donkeyMain.ml
--- ./src/networks/donkey/donkeyMain.ml	2004-05-03 10:22:25.000000000 +0200
+++ ./src/networks/donkey/donkeyMain.ml	2004-05-31 18:00:41.000000000 +0200
@@ -75,9 +75,7 @@
   (try
       DonkeySources.connect_sources connection_manager;
     with e ->
-        if !verbose_sources then 
-          lprintf "Exception %s while checking sources\n" 
-            (Printexc2.to_string e)
+        BLOG DEBUG (!verbose_sources) : "Exception %s while checking sources\n" (Printexc2.to_string e) ELOG
   )
 
 let halfmin_timer timer =
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/donkey/donkeyNeighbours.ml ./src/networks/donkey/donkeyNeighbours.ml
--- ./src/networks/donkey/donkeyNeighbours.ml	2004-04-16 19:14:55.000000000 +0200
+++ ./src/networks/donkey/donkeyNeighbours.ml	2004-05-31 18:00:52.000000000 +0200
@@ -109,7 +109,7 @@
       match r with
       | File_new_source ->
           if time + 1800 < last_time () then begin
-              lprintf "DonkeyNeighbours: WARNING, source was not tested\n";
+              BLOG DEBUG : "DonkeyNeighbours: WARNING, source was not tested\n" ELOG;
               raise Continue
             end
       | File_expected  ->
@@ -132,7 +132,7 @@
     with
     | Not_found -> 
 (* For some reason, the request was forgotten. Forget it... *)
-        lprintf "DonkeyNeighbours: ERROR, request was forgotten\n";
+        BLOG DEBUG : "DonkeyNeighbours: ERROR, request was forgotten\n" ELOG;
         let _ = Fifo.take propositions in
         compute_stats ()
     | Continue ->         
@@ -151,7 +151,7 @@
         DonkeySources.set_request_result s file.file_sources File_new_source;
         Fifo.put propositions (s, file, kind, last_time ())
     | _ -> 
-        lprintf "DonkeyNeighbours: ERROR, proposed client is indirect\n";
+        BLOG DEBUG : "DonkeyNeighbours: ERROR, proposed client is indirect\n" ELOG;
         raise Exit
         
   with Exit -> 
@@ -375,18 +375,18 @@
       compute_stats ();
       let len = Array.length ngood_propositions in
       buf_int buf len;
-      lprintf "DonkeyNeighbours stats:\n";
+      BLOG INFO : "DonkeyNeighbours stats:\n" ELOG;
       for i = 0 to len - 1 do
-        lprintf "   Good[%d] = %Ld\n" i ngood_propositions.(i);
-        lprintf "   Bad[%d] = %Ld\n" i nbad_propositions.(i);
+        BLOG INFO : "   Good[%d] = %Ld\n" (i) (ngood_propositions.(i)) ELOG;
+        BLOG INFO : "   Bad[%d] = %Ld\n" (i) (nbad_propositions.(i)) ELOG;
         buf_int64 buf ngood_propositions.(i);
         buf_int64 buf nbad_propositions.(i)
       done;
       let len = Fifo.length propositions in
-      lprintf "   Waiting propositions: %d\n" len;
+      BLOG INFO : "   Waiting propositions: %d\n" (len) ELOG;
       buf_int buf len;
       let len = ref 0 in
       Hashtbl.iter (fun _ _ -> incr len) neighbours;
-      lprintf "   Total neighbours: %d\n" !len;
+      BLOG INFO : "   Total neighbours: %d\n" (!len) ELOG;
       buf_int buf !len
   )
\ Kein Zeilenumbruch am Dateiende.
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/donkey/donkeyOneFile.ml ./src/networks/donkey/donkeyOneFile.ml
--- ./src/networks/donkey/donkeyOneFile.ml	2004-05-03 10:22:25.000000000 +0200
+++ ./src/networks/donkey/donkeyOneFile.ml	2004-05-31 18:00:52.000000000 +0200
@@ -444,10 +444,7 @@
           b.block_zones <- create_zones file b.block_begin b.block_end [];
 
           b.block_nclients <- 1;
-          if !verbose then begin
-              lprintf "\n%d: NEW BLOCK [%Ld - %Ld]\n" (client_num c)
-              (b.block_begin) (b.block_end);
-            end;
+          BLOG DEBUG (!verbose) : "\n%d: NEW BLOCK [%Ld - %Ld]\n" (client_num c) (b.block_begin) (b.block_end) ELOG;
           zero_block file i;
           b.block_legacy <- false;
           c.client_block <- Some b;
@@ -467,11 +464,9 @@
 (*              lprintf "client %d: downloading partial block %d \n"
                 (client_num c) b.block_pos; *)
 
-              if !verbose then begin
-                  lprintf "\n%d: NEW CLIENT FOR BLOCK [%Ld - %Ld]\n"
-                    (client_num c)
-                  (b.block_begin) (b.block_end);
-                end;
+              BLOG DEBUG (!verbose) : "\n%d: NEW CLIENT FOR BLOCK [%Ld - %Ld]\n"
+	        (client_num c) (b.block_begin) (b.block_end)
+	      ELOG;
 
               file.file_chunks.(i) <- PartialVerified b;
               find_client_zone c;
@@ -495,14 +490,13 @@
       match c.client_file_queue with
         [] -> ()
       | [ (file, chunks, up) ] ->
-          if !verbose_download || c.client_debug then begin
-              lprintf "sort_file_queue: single file. client(%d): %s, file(%d): %s\n" (client_num c) c.client_name (file_num file) (file_best_name file);
-            end
+          BLOG DEBUG (!verbose_download || c.client_debug) : "sort_file_queue: single file. client(%d): %s, file(%d): %s\n"
+	   (client_num c) (c.client_name) (file_num file) (file_best_name file) ELOG
       | (file, chunks, up) :: _ ->
           let fn = file_num file in
-          if !verbose_download || c.client_debug then begin
-              lprintf "sort_file_queue: multiple files. client(%d): %s, file(%d): %s\n" (client_num c) c.client_name (file_num file) (file_best_name file);
-            end;
+          BLOG DEBUG (!verbose_download || c.client_debug) : "sort_file_queue: multiple files. client(%d): %s, file(%d): %s\n"
+	   (client_num c) (c.client_name) (file_num file) (file_best_name file)
+          ELOG;
           c.client_file_queue <- List.stable_sort (fun (f1, _, _) (f2, _, _) ->
               let v = file_priority f2 - file_priority f1 in
               if v <> 0 then v else
@@ -518,9 +512,9 @@
             [] -> ()
           | (file, chunks, _) :: _ ->
               if (file_num file) <> fn then begin
-                  if !verbose_download || c.client_debug then begin
-                      lprintf "sort_file_queue: queue change. client(%d): %s, file(%d): %s\n" (client_num c) c.client_name (file_num file) (file_best_name file);
-                    end;
+                  BLOG DEBUG (!verbose_download || c.client_debug) : "sort_file_queue: queue change. client(%d): %s, file(%d): %s\n"
+		   (client_num c) (c.client_name) (file_num file) (file_best_name file)
+                  ELOG;
 (*
 (*                  c.client_chunks <- chunks; *)
 (*                  c.client_all_chunks <- String.make file.file_nchunks '0'; *)
@@ -588,31 +582,23 @@
 and find_client_block c =
 (* find an available block *)
 
-  if !verbose_download || c.client_debug then begin
-      lprintf "find_client_block: started\n";
-    end;
+  BLOG DEBUG (!verbose_download || c.client_debug) : "find_client_block: started\n" ELOG;
   sort_file_queue c;
   match c.client_file_queue with
     [] ->
 (* Emule may reconnect and give the slot without us asking for it.
     We have to fix this behavior in the future. *)
-      if !verbose_download || c.client_debug then begin
-          lprintf "Client %d: NO FILE IN QUEUE\n" (client_num c);
-        end
+      BLOG DEBUG (!verbose_download || c.client_debug) : "Client %d: NO FILE IN QUEUE\n" (client_num c) ELOG;
 
   | (file, (chunks)) :: files ->
 
-      if !verbose_download || c.client_debug then begin
-          lprintf "File %s state %s\n"
-            (file_best_name file)
-          (string_of_file_state
-              (file_state file));
-        end;
+      BLOG DEBUG (!verbose_download || c.client_debug) : "File %s state %s\n"
+        (file_best_name file)
+        (string_of_file_state (file_state file))
+      ELOG;
       if file_state file <> FileDownloading then next_file c else
 
-      if !verbose_download || c.client_debug then begin
-          lprintf "find_client_block: continuing\n";
-        end;
+      BLOG DEBUG (!verbose_download || c.client_debug) : "find_client_block: continuing\n" ELOG;
 
       if !verbose || c.client_debug  then begin
           for i = 0 to file.file_nchunks - 1 do
@@ -644,9 +630,7 @@
 
           if !!random_order_download then begin
 
-              if !verbose_download || c.client_debug then begin
-                  lprintf "find_client_block: random_order_download\n";
-                end;
+              BLOG DEBUG (!verbose_download || c.client_debug) : "find_client_block: random_order_download\n" ELOG;
 
  	      let proportional_check_file_block c file i force =
  	        let n = 1 + (((!!sources_per_chunk-1) * Int64.to_int (chunk_compute_missing file i)) / Int64.to_int block_size) in
@@ -728,11 +712,7 @@
 
             end else begin
 
-              if !verbose_download then begin
-                  lprintf "find_client_block: NOT RANDOM ORDER (last = %d)\n"
-                  last;
-
-                end;
+              BLOG DEBUG (!verbose_download) : "find_client_block: NOT RANDOM ORDER (last = %d)\n" (last) ELOG;
 
               if c.client_chunks.(last) then
                 check_file_block c file last max_int force;
@@ -812,11 +792,9 @@
       with
 	  Block_selected -> ()
 	| e ->
-          if !verbose_download || c.client_debug then begin
-              lprintf "find_client_block: exception %s\n"
-                (Printexc2.to_string e);
-              ()
-            end
+          BLOG DEBUG (!verbose_download || c.client_debug) : "find_client_block: exception %s\n"
+                (Printexc2.to_string e)
+          ELOG
 
 and next_file c =
 
@@ -962,10 +940,7 @@
 
       file_must_update file;
       z.zone_begin <- z.zone_end;
-      if !verbose && end_pos > z.zone_end then begin
-          lprintf "EXCEEDING: %Ld>%Ld\n" (end_pos)
-          (z.zone_end);
-        end
+      BLOG DEBUG (!verbose && end_pos > z.zone_end) : "EXCEEDING: %Ld>%Ld\n" (end_pos) (z.zone_end) ELOG
 
     end else
   if z.zone_begin >= begin_pos && z.zone_begin < end_pos then begin
@@ -1133,9 +1108,7 @@
   
   if !change_last_seen then begin
       try
-        if !verbose_download then begin
-            lprintf "client_has_chunks: change_last_seen\n"; 
-          end;
+        BLOG DEBUG (!verbose_download) : "client_has_chunks: change_last_seen\n" ELOG;
         
         let last_seen =  Array2.min file.file_chunks_age in
         if last_seen > file.file_file.impl_file_last_seen then
@@ -1163,18 +1136,14 @@
 with Not_found ->
   *)
           add_client_chunks file chunks;
-          if !verbose_download then begin
-              lprintf "client_file_queue: ADDING FILE TO QUEUE\n"; 
-            end;
+          BLOG DEBUG (!verbose_download) : "client_file_queue: ADDING FILE TO QUEUE\n" ELOG;
           c.client_file_queue <- c.client_file_queue @ [
             file, chunks ]
         );
         start_download c
       
       with _ -> 
-          if !verbose_download then begin
-              lprintf "client_has_chunks: EXCEPTION\n"; 
-            end
+          BLOG DEBUG (!verbose_download) : "client_has_chunks: EXCEPTION\n" ELOG
     end
 
 *)
@@ -1217,8 +1186,9 @@
           
           let downloaded = Int64Swarmer.downloaded swarmer in
           if file_downloaded file <> downloaded then begin
-              lprintf "ERROR: file_downloaded file (%Ld) <> downloaded swarmer (%Ld)\n"
-                (file_downloaded file) downloaded
+              BLOG ERROR : "file_downloaded file (%Ld) <> downloaded swarmer (%Ld)\n"
+                (file_downloaded file) (downloaded) ELOG;
+		()
             end;
           
           if verified then begin
@@ -1434,9 +1404,7 @@
   or start querying blocks if already in the queue *)
 let request_slot c = 
     if c.client_slot = SlotNotAsked then begin
-      if !verbose_download then begin
-          lprintf "start_download...\n";
-        end;
+      BLOG DEBUG (!verbose_download) : "start_download...\n" ELOG;
       do_if_connected c.client_source.DonkeySources.source_sock (fun sock ->
           sort_file_queue c;
           match c.client_file_queue with
@@ -1454,11 +1422,11 @@
     
   match c.client_download with
     None -> 
-      lprintf "DonkeyOneFile.block_received: block received but no file !\n  Received: %s\n" (Md4.to_string md4)
+      BLOG DEBUG : "DonkeyOneFile.block_received: block received but no file !\n  Received: %s\n" (Md4.to_string md4) ELOG
   | Some (file, up) ->
       
       if file.file_md4 <> md4 then begin
-          lprintf "DonkeyOneFile.block_received: block for bad file\n  Received: %s\n  Expected: %s\n" (Md4.to_string md4) (Md4.to_string file.file_md4)
+          BLOG DEBUG : "DonkeyOneFile.block_received: block for bad file\n  Received: %s\n  Expected: %s\n" (Md4.to_string md4) (Md4.to_string file.file_md4) ELOG
         end else begin
           DonkeySources.set_request_result c.client_source file.file_sources File_upload;
           
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/donkey/donkeyServers.ml ./src/networks/donkey/donkeyServers.ml
--- ./src/networks/donkey/donkeyServers.ml	2004-05-05 22:55:37.000000000 +0200
+++ ./src/networks/donkey/donkeyServers.ml	2004-05-31 18:00:41.000000000 +0200
@@ -259,8 +259,8 @@
       s.server_nfiles <- files;
       if (users < !!min_users_on_server) then
         begin
-          lprintf "%s:%d remove server min_users_on_server limit hit!"
-            (Ip.to_string s.server_ip) s.server_port; print_newline ();
+          BLOG DEBUG : "%s:%d remove server min_users_on_server limit hit!\n"
+            (Ip.to_string s.server_ip) (s.server_port) ELOG;
           
           disconnect_server s Closed_for_timeout;
           server_remove (as_server s.server_server);
@@ -497,7 +497,7 @@
   force_check_server_connections false
 
 let remove_old_servers () =
-  lprintf "REMOVE OLD SERVERS\n";  
+  BLOG DEBUG : "REMOVE OLD SERVERS\n" ELOG;
   let t1 = Unix.gettimeofday () in
 (*
 The new tactic: we sort the servers (the more recently connected first,
@@ -514,38 +514,38 @@
         to_keep := (connection_last_conn s.server_connection_control, s) :: 
         !to_keep
   ) servers_by_key;
-  let t2 = Unix.gettimeofday () in
-  lprintf "Delay to detect black-listed servers: %2.2f\n" (t2 -. t1); 
   
+  let t2 = Unix.gettimeofday () in
+  BLOG DEBUG : "Delay to detect black-listed servers: %2.2f\n" (t2 -. t1) ELOG;
+
   if List.length !to_keep > !!min_left_servers then begin
   let array = Array.of_list !to_keep in
   Array.sort (fun (ls1,_) (ls2,_) ->
       if ls1 = ls2 then 0 else if ls1 > ls2 then -1 else 1
   ) array;
 
-  if !verbose then 
+  BLOG DEBUG (!verbose) #
+    begin
     for i = 0 to Array.length array - 1 do
       let ls, s = array.(i) in
-      lprintf "server %d last_conn %d\n" (server_num s) ls;
-      
+      BLOG DEBUG : "server %d last_conn %d\n" (server_num s) (ls) ELOG;
     done;
+    end
+  ELOG;
 
   let min_last_conn =  last_time () - !!max_server_age * Date.day_in_secs in
   
   for i = Array.length array - 1 downto !!min_left_servers do
     let ls, s = array.(i) in
     if ls < min_last_conn && s.server_sock = NoConnection then begin
-        if !verbose then begin
-            lprintf "Server too old: %s:%d\n" 
-              (Ip.to_string s.server_ip) s.server_port;
-            
-          end;
+        BLOG DEBUG (!verbose) : "Server too old: %s:%d\n" 
+              (Ip.to_string s.server_ip) (s.server_port) ELOG;
         to_remove := s :: !to_remove
       end
   done;
   end;
   let t3 = Unix.gettimeofday () in
-  lprintf "Delay to detect old servers: %2.2f\n" (t3 -. t2); 
+  BLOG DEBUG : "Delay to detect old servers: %2.2f\n" (t3 -. t2) ELOG;
 
   List.iter (fun s ->
       server_remove (as_server s.server_server);
@@ -553,7 +553,7 @@
   !to_remove;
 
   let t4 = Unix.gettimeofday () in
-  lprintf "Delay to finally remove servers: %2.2f\n" (t4 -. t3);   
+  BLOG DEBUG : "Delay to finally remove servers: %2.2f\n" (t4 -. t3) ELOG;
 (*
   let removed_servers = ref [] in
   let servers_left = ref 0 in
@@ -569,7 +569,7 @@
     end else begin
       lprintf "Not enough remaining servers: %d\n" !servers_left;  
     end; *)
-  lprintf "REMOVE %d OLD SERVERS DONE\n" (List.length !to_remove)
+  BLOG DEBUG : "REMOVE %d OLD SERVERS DONE\n" (List.length !to_remove) ELOG
 
   
 (* Don't let more than max_allowed_connected_servers running for
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/donkey/donkeyShare.ml ./src/networks/donkey/donkeyShare.ml
--- ./src/networks/donkey/donkeyShare.ml	2004-05-03 10:22:25.000000000 +0200
+++ ./src/networks/donkey/donkeyShare.ml	2004-05-31 18:00:46.000000000 +0200
@@ -162,11 +162,11 @@
         let rec job_creater _ =
           try
             if not (Sys.file_exists sh.shared_name) then begin
-                lprintf "Shared file doesn't exist\n"; 
+                BLOG DEBUG : "Shared file doesn't exist\n" ELOG;
                 raise Not_found;
               end;
             if Unix32.getsize sh.shared_name <> sh.shared_size then begin
-                lprintf "Bad shared file size\n" ; 
+                BLOG DEBUG : "Bad shared file size\n" ELOG;
                 raise Not_found;
               end;
             computation := true;
@@ -195,7 +195,7 @@
                         sh_md4s = Array.of_list (List.rev sh.shared_list);
                         sh_mtime = Unix32.mtime sh.shared_name;
                       } in
-                    lprintf "NEW SHARED FILE %s\n" sh.shared_name; 
+                    BLOG INFO : "NEW SHARED FILE %s\n" (sh.shared_name) ELOG;
                     Hashtbl.add shared_files_info sh.shared_name s;
                     known_shared_files =:= s :: !!known_shared_files;
                     new_file_to_share s sh.shared_shared.impl_shared_codedname (Some  sh.shared_shared);
@@ -204,9 +204,8 @@
                 else
                   job_creater ())
           with e ->
-              lprintf "Exception %s prevents sharing"
-                (Printexc2.to_string e);
-              lprint_newline ();
+              BLOG DEBUG : "Exception %s prevents sharing\n"
+                (Printexc2.to_string e) ELOG; ();
         in
         job_creater ()
         
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/donkey/donkeyThieves.ml ./src/networks/donkey/donkeyThieves.ml
--- ./src/networks/donkey/donkeyThieves.ml	2003-12-02 23:56:42.000000000 +0100
+++ ./src/networks/donkey/donkeyThieves.ml	2004-05-31 18:00:41.000000000 +0200
@@ -100,8 +100,7 @@
 	| _, _, _ ->
 	    (* it switched to a hash that's used somewhere else, 
 	       that's certainly a theft. *)
-	    lprintf "That hash was already used somewhere else, that's certainly a theft!";
-            lprint_newline ();
+	    BLOG DEBUG : "That hash was already used somewhere else, that's certainly a theft!\n" ELOG;
 	    false
 ;;
 let clean_thieves () =
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/donkey/donkeyUdp.ml ./src/networks/donkey/donkeyUdp.ml
--- ./src/networks/donkey/donkeyUdp.ml	2004-05-05 22:55:37.000000000 +0200
+++ ./src/networks/donkey/donkeyUdp.ml	2004-05-31 18:00:43.000000000 +0200
@@ -279,5 +279,4 @@
       
       
   | _ -> 
-      lprintf "Unexpected UDP message: \n%s\n"
-        (DonkeyProtoUdp.print t)
+      BLOG DEBUG : "Unexpected UDP message: \n%s\n" (DonkeyProtoUdp.print t) ELOG; ()
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/fileTP/fileTPComplexOptions.ml ./src/networks/fileTP/fileTPComplexOptions.ml
--- ./src/networks/fileTP/fileTPComplexOptions.ml	2004-05-03 10:22:25.000000000 +0200
+++ ./src/networks/fileTP/fileTPComplexOptions.ml	2004-05-31 18:00:52.000000000 +0200
@@ -133,9 +133,9 @@
       "file_id", string_to_value (Md4.to_string file.file_id);
       "file_sources", 
       list_to_value "FileTP Sources" (fun c ->
-          lprintf "SAVING: find_client...\n";
+          BLOG DEBUG : "SAVING: find_client...\n" ELOG;
           let n = (find_download file c.client_downloads).download_url in
-          lprintf "SAVING: find_client...done...saving\n"; 
+          BLOG DEBUG : "SAVING: find_client...done...saving\n" ELOG;
           SmallList [ClientOption.client_to_value c; 
             string_to_value (Url.to_string n)]
       ) file.file_clients;
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/fileTP/fileTPGlobals.ml ./src/networks/fileTP/fileTPGlobals.ml
--- ./src/networks/fileTP/fileTPGlobals.ml	2004-05-03 10:22:25.000000000 +0200
+++ ./src/networks/fileTP/fileTPGlobals.ml	2004-05-31 18:00:52.000000000 +0200
@@ -109,9 +109,9 @@
 let min_range_size = megabyte
 
 let set_file_size file size =  
-  lprintf "set_file_size\n";
+  BLOG DEBUG : "set_file_size\n" ELOG;
   if file_size file = zero && size <> zero then begin
-      lprintf "Setting SWARMER\n";
+      BLOG DEBUG : "Setting SWARMER\n" ELOG;
       let file_chunk_size =
         max megabyte (
           size // (max (Int64.of_int 5) (size // (megabytes 5)))
@@ -121,7 +121,7 @@
       let swarmer = Int64Swarmer.create (as_file file) 
           file_chunk_size min_range_size in
       file.file_swarmer <- Some swarmer;    
-      lprintf "Swarmer set\n";
+      BLOG DEBUG : "Swarmer set\n" ELOG;
       Int64Swarmer.set_verifier swarmer (fun _ _ _ ->
           file_must_update (as_file file);
           true  
@@ -217,7 +217,7 @@
 let add_download file c url =
 (*  let r = new_result file.file_name (file_size file) in *)
 (*  add_source r c.client_user index; *)
-  lprintf "Adding file to client\n";
+  BLOG DEBUG : "Adding file to client\n" ELOG;
   if not (List.memq c file.file_clients) then begin
       let chunks = [ Int64.zero, file_size file ] in
       (*
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/fileTP/fileTPInteractive.ml ./src/networks/fileTP/fileTPInteractive.ml
--- ./src/networks/fileTP/fileTPInteractive.ml	2004-05-03 10:22:25.000000000 +0200
+++ ./src/networks/fileTP/fileTPInteractive.ml	2004-05-31 18:00:52.000000000 +0200
@@ -307,7 +307,7 @@
   
   let file = new_file (Md4.random ()) u.Url.full_file zero in
   
-  lprintf "DOWNLOAD FILE %s\n" (file_best_name  file); 
+  BLOG DEBUG : "DOWNLOAD FILE %s\n" (file_best_name  file) ELOG; 
   if not (List.memq file !current_files) then begin
       current_files := file :: !current_files;
     end;
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/soulseek/slskClients.ml ./src/networks/soulseek/slskClients.ml
--- ./src/networks/soulseek/slskClients.ml	2004-05-03 10:22:25.000000000 +0200
+++ ./src/networks/soulseek/slskClients.ml	2004-05-31 18:00:45.000000000 +0200
@@ -56,13 +56,13 @@
       cancel_token token;
       c.client_peer_sock <- NoConnection
   | Connection sock ->
-      lprintf "DISCONNECTED FROM PEER"; lprint_newline ();
+      BLOG DEBUG : "DISCONNECTED FROM PEER\n" ELOG;
       close sock reason;
       c.client_peer_sock <- NoConnection;
       c.client_requests <- []
 
 let disconnect_result c sock =
-  lprintf "DISCONNECTED FROM RESULT"; lprint_newline ();
+  BLOG DEBUG : "DISCONNECTED FROM RESULT\n" ELOG;
   close sock Closed_by_user;
   c.client_result_socks <- List2.removeq sock c.client_result_socks
   
@@ -76,7 +76,7 @@
       let subdir_option = commit_in_subdir
       
       let client_disconnected d =
-        lprintf "DISCONNECTED FROM SOURCE"; lprint_newline ();
+        BLOG DEBUG : "DISCONNECTED FROM SOURCE\n" ELOG;
         let c = d.download_client in
         c.client_downloads <- List2.removeq d c.client_downloads
       
@@ -115,16 +115,15 @@
         ()
   
   with e ->
-      lprintf "Exception %s while connecting to client" 
-        (Printexc2.to_string e);
-      lprint_newline ()
+      BLOG DEBUG : "Exception %s while connecting to client\n" 
+        (Printexc2.to_string e) ELOG; ()
 
 let client_to_client c t sock =
-  if !verbose_msg_clients then begin
-      lprintf "MESSAGE FROM PEER"; lprint_newline ();
+  BLOG DEBUG #
+      BLOG DEBUG (!verbose_msg_clients) : "MESSAGE FROM PEER\n" ELOG;
       C2C.print t;
       lprint_newline ();
-    end;
+  ELOG;
   
   match t with
   | C2C.FileSearchResultReq t ->
@@ -140,14 +139,12 @@
                 add_result_source r u file.C2C.file_name;
                 search_add_result true q r.result_result
               with e ->
-                  lprintf "Exception %s for file %s" 
-                    (Printexc2.to_string e) file.C2C.file_name;
-                  lprint_newline ();
+                  BLOG DEBUG : "Exception %s for file %s\n"
+                    (Printexc2.to_string e) (file.C2C.file_name) ELOG;
             ) t.SR.files;
             ()
       with Not_found ->
-          lprintf "******* NO SEARCH ASSOCIATED WITH %d ******"
-            t.SR.id; lprint_newline ();
+          BLOG DEBUG : "******* NO SEARCH ASSOCIATED WITH %d ******\n" (t.SR.id) ELOG; ();
       end
 
   | C2C.TransferRequestReq (false, req_id, file_name, size) ->
@@ -157,9 +154,9 @@
           let short_file_name = Filename2.basename file_name in
           let file = Hashtbl.find files_by_key (String.lowercase file_name) in
           
-          lprintf "File Found"; lprint_newline ();
+          BLOG DEBUG : "File Found\n" ELOG;
           if size <> file_size file then begin
-              lprintf "Bad file size"; lprint_newline ();
+              BLOG DEBUG : "Bad file size\n" ELOG;
               raise Exit
             end;
           if file_state file = FileDownloading then begin
@@ -174,8 +171,8 @@
             end
           
         with e ->
-            lprintf "Exception %s for TransferRequestReq Upload %s:%Ld"
-              (Printexc2.to_string e) file_name size; lprint_newline ();
+            BLOG DEBUG : "Exception %s for TransferRequestReq Upload %s:%Ld\n"
+              (Printexc2.to_string e) (file_name) (size) ELOG; ();
       end
       
   | C2C.SharedFileListReq files ->
@@ -196,7 +193,7 @@
           connect_download c file req
         with
           Not_found ->
-            lprintf "req %d not found !" req; lprint_newline ();
+            BLOG DEBUG : "req %d not found !\n" (req) ELOG; ();
       end      
 
   | C2C.TransferFailedReplyReq (req, reason) ->
@@ -211,7 +208,7 @@
             update_file_state (file.file_file) (FileAborted reason)
         with
           Not_found ->
-            lprintf "req %d not found !" req; lprint_newline ();
+            BLOG DEBUG : "req %d not found !\n" (req) ELOG; ();
       end      
       
   | _ -> 
@@ -220,9 +217,7 @@
       lprint_newline () 
 
 let connect_peer c token msgs =
-  if !verbose_msg_clients then begin
-      lprintf "CONNECT PEER"; lprint_newline ();
-    end;
+  BLOG DEBUG (!verbose_msg_clients) : "CONNECT PEER\n" ELOG;
   match c.client_peer_sock with
     Connection sock -> 
       List.iter (fun t -> client_send sock t) msgs
@@ -230,15 +225,10 @@
   | NoConnection ->
       match c.client_addr with
         None -> 
-          if !verbose_msg_clients then begin
-              lprintf "NO ADDRESS FOR CLIENT"; lprint_newline ();
-            end;
+          BLOG DEBUG (!verbose_msg_clients) : "NO ADDRESS FOR CLIENT\n" ELOG;
           List.iter (fun s ->
               do_if_connected s.server_sock (fun sock ->
-                  if !verbose_msg_servers then begin
-                      lprintf "ASKING FOR CLIENT IP: %s"  c.client_name;
-                      lprint_newline ();
-                    end;
+                  BLOG DEBUG (!verbose_msg_servers) : "ASKING FOR CLIENT IP: %s\n" (c.client_name) ELOG;
                   server_send sock (C2S.GetPeerAddressReq c.client_name);
               )
           ) !connected_servers
@@ -248,9 +238,7 @@
             add_pending_connection connection_manager (fun ctoken ->
                 c.client_peer_sock <- NoConnection;
                 try
-                  if !verbose_msg_clients then begin
-                      lprintf "CONNECTING"; lprint_newline ();
-                    end;
+                  BLOG DEBUG (!verbose_msg_clients) : "CONNECTING\n" ELOG;
                   connection_try c.client_connection_control;      
                   let sock = connect ctoken "peer connect" 
                       (Ip.to_inet_addr ip) port
@@ -266,8 +254,8 @@
                   init_peer_connection  sock (local_login ()) token;
                   List.iter (fun t -> client_send sock t) msgs
                 with e ->
-                    lprintf "Exception %s while connecting to client\n" 
-                      (Printexc2.to_string e);
+                    BLOG DEBUG : "Exception %s while connecting to client\n" 
+                      (Printexc2.to_string e) ELOG;
                     disconnect_peer c (Closed_for_exception e)
             ) in
           c.client_peer_sock <- ConnectionWaiting token
@@ -278,9 +266,7 @@
   | Some (ip,port) ->
       let ctoken = add_pending_connection connection_manager (fun ctoken ->
             try
-              if !verbose_msg_clients then begin
-                  lprintf "CONNECTING"; lprint_newline ();
-                end;
+              BLOG DEBUG (!verbose_msg_clients) : "CONNECTING\n" ELOG;
               connection_try c.client_connection_control;      
               let sock = connect ctoken "peer connect" 
                   (Ip.to_inet_addr ip) port
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/soulseek/slskGlobals.ml ./src/networks/soulseek/slskGlobals.ml
--- ./src/networks/soulseek/slskGlobals.ml	2004-01-30 07:11:06.000000000 +0100
+++ ./src/networks/soulseek/slskGlobals.ml	2004-05-31 18:00:45.000000000 +0200
@@ -255,7 +255,7 @@
       let current_size = try
           Unix32.getsize file_temp
         with e ->
-            lprintf "Exception %s in current_size\n" (Printexc2.to_string e); 
+            BLOG DEBUG : "Exception %s in current_size\n" (Printexc2.to_string e) ELOG;
             Int64.zero
       in
       
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/soulseek/slskInteractive.ml ./src/networks/soulseek/slskInteractive.ml
--- ./src/networks/soulseek/slskInteractive.ml	2004-04-16 19:14:56.000000000 +0200
+++ ./src/networks/soulseek/slskInteractive.ml	2004-05-31 18:00:45.000000000 +0200
@@ -79,17 +79,17 @@
       
       in
       iter query;
-      lprintf "SEARCH ADDED FOR %d" !!next_token; lprint_newline ();
+      BLOG DEBUG : "SEARCH ADDED FOR %d\n" (!!next_token) ELOG;
       SlskGlobals.searches := (!!next_token, q) :: !SlskGlobals.searches;
       let words = String2.unsplit !words ' ' in
-      lprintf "SEARCH COMPUTED"; lprint_newline ();
+      BLOG DEBUG : "SEARCH COMPUTED\n" ELOG;
       let msg = C2S.FileSearchReq {
           C2S.FileSearch.words = words;
           C2S.FileSearch.id = !!next_token;
         } in
       List.iter (fun s ->
           do_if_connected s.server_sock (fun sock ->
-              lprintf "SENDING SEARCH"; lprint_newline ();
+              BLOG DEBUG : "SENDING SEARCH\n" ELOG;
               server_send sock msg; 
               s.server_search <- Some q; 
               Printf.bprintf  buf "Sending search\n") 
@@ -259,7 +259,7 @@
       }
   );
   client_ops.op_client_browse <- (fun c immediate ->
-      lprintf "CLIENT BROWSE !!!!"; lprint_newline ();
+      BLOG DEBUG : "CLIENT BROWSE !!!!\n" ELOG;
       SlskClients.connect_peer c 300 [C2C.GetSharedFileListReq]
   )
 
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/networks/soulseek/slskProtocol.ml ./src/networks/soulseek/slskProtocol.ml
--- ./src/networks/soulseek/slskProtocol.ml	2004-03-07 10:34:28.000000000 +0100
+++ ./src/networks/soulseek/slskProtocol.ml	2004-05-31 18:00:45.000000000 +0200
@@ -85,8 +85,10 @@
   }, pos + 28
   
 let unknown opcode s =
-  lprintf "Unknown: opcode %d\n" opcode; 
-  dump s
+  BLOG DEBUG #
+    BLOG DEBUG : "Unknown: opcode %d\n" (opcode) ELOG;
+    dump s
+  ELOG
   
 module C2S = struct
     
@@ -104,8 +106,8 @@
           { login = login; password = password; version = version; }
         
         let print t =
-          lprintf "LOGIN login:%s password:%s version:%d\n" 
-            t.login t.password t.version
+          BLOG DEBUG : "LOGIN login:%s password:%s version:%d\n" 
+            (t.login) (t.password) (t.version) ELOG
           
         
         let write buf t =
@@ -121,7 +123,7 @@
         let parse s =  get_int s 0
         
         let print t =
-          lprintf "SETWAITPORT %d\n" t
+          BLOG DEBUG : "SETWAITPORT %d\n" (t) ELOG
           
         let write buf t =
           buf_int buf t
@@ -140,7 +142,7 @@
           { id = id; words = s }
         
         let print t =
-          lprintf "SEARCH %d FOR %s\n" t.id t.words
+          BLOG DEBUG : "SEARCH %d FOR %s\n" (t.id) (t.words) ELOG
           
         let write buf t =
           buf_int buf t.id;
@@ -229,8 +231,9 @@
         | _ -> raise Not_found
       with
         e -> 
-          lprintf "From client\n"; 
-          unknown opcode s;
+          BLOG DEBUG #
+              BLOG DEBUG : "From client\n" ELOG;
+              unknown opcode s ELOG;
           UnknownReq (opcode, s)
 
           
@@ -240,19 +243,19 @@
       | SetWaitPortReq t -> SetWaitPort.print t  
       | FileSearchReq t -> FileSearch.print t   
       | GetUserStatsReq t -> 
-          lprintf "GetUserStats %s\n" t
+          BLOG DEBUG : "GetUserStats %s\n" (t) ELOG
       | JoinRoomReq t -> 
-          lprintf "JoinRoomReq %s\n" t
+          BLOG DEBUG : "JoinRoomReq %s\n" (t) ELOG
       | LeaveRoomReq t -> 
-          lprintf "LeaveRoomReq %s\n" t
+          BLOG DEBUG : "LeaveRoomReq %s\n" (t) ELOG
       | AddUserReq t -> 
-          lprintf "AddUserReq %s\n" t;
+          BLOG DEBUG : "AddUserReq %s\n" (t) ELOG
       | GetPeerAddressReq t -> 
-          lprintf "GetPeerAddressReq %s\n" t
+          BLOG DEBUG : "GetPeerAddressReq %s\n" (t) ELOG
       | CantConnectToPeerReq t -> 
-          lprintf "CantConnectToPeerReq %s\n" t
+          BLOG DEBUG : "CantConnectToPeerReq %s\n" (t) ELOG
       | SayChatroomReq (room, msg) -> 
-          lprintf "SayChatroomReq %s: %s\n" room msg
+          BLOG DEBUG : "SayChatroomReq %s: %s\n" (room) (msg) ELOG
       | UnknownReq (opcode, s) ->  unknown opcode s
           
     let write buf t =
@@ -294,10 +297,10 @@
         let print t =
           match t with
             Success (message, ip) ->
-              lprintf "LOGIN ACK: %s\n" message;
-              lprintf "   IP: %s\n" (Ip.to_string ip)
+              BLOG DEBUG : "LOGIN ACK: %s\n" (message) ELOG;
+              BLOG DEBUG : "   IP: %s\n" (Ip.to_string ip) ELOG
           | Failure reason ->
-              lprintf "LOGIN FAILURE %s\n" reason
+              BLOG WARN : "LOGIN FAILURE %s\n" (reason) ELOG
         
         let write buf t =
           match t with
@@ -346,10 +349,12 @@
 *)
         
         let print t =
-          lprintf "Room list: %d rooms\n" (List.length t);
+          BLOG DEBUG #
+          BLOG DEBUG : "Room list: %d rooms\n" (List.length t) ELOG;
           List.iter (fun (name, nusers) ->
-              lprintf "    %50s  %-10d\n" name nusers;
+              ldebug "    %50s  %-10d\n" name nusers;
           ) t
+	  ELOG
         
         let write buf t =
           buf_list (fun buf (name,_) -> buf_string buf name) buf t;
@@ -365,9 +370,11 @@
           users
         
         let print t =
-          lprintf "PRIVILEDGED USERS\n:"; 
-          List.iter (fun u -> lprintf "%s\n" u) t;
+          BLOG DEBUG #
+          BLOG DEBUG : "PRIVILEDGED USERS\n:" ELOG;
+          List.iter (fun u -> ldebug "%s\n" u) t;
           lprint_newline ()
+	  ELOG
         
         let write buf t =
           buf_list buf_string buf t
@@ -398,8 +405,8 @@
           }
         
         let print t =
-          lprintf "CONNECT TO PEER %s (%s:%d) token %d\n"
-            t.name (Ip.to_string t.ip) t.port t.token
+          BLOG DEBUG : "CONNECT TO PEER %s (%s:%d) token %d\n"
+            (t.name) (Ip.to_string t.ip) (t.port) (t.token) ELOG
         
         let write buf t =
           buf_string buf t.name;
@@ -437,13 +444,15 @@
             users stats; }
         
         let print t =
-          lprintf "JOIN ROOM %s\n:" t.room; 
+          BLOG DEBUG #
+          BLOG DEBUG : "JOIN ROOM %s\n:" (t.room) ELOG; 
           List.iter (fun u ->
-              lprintf "   %s\n" u.name) t.users;
+              ldebug "   %s\n" u.name) t.users;
           lprint_newline ()
+	  ELOG
         
         let write buf t =
-          lprintf  "******* JoinRoomReply not implemented *****\n"; 
+          BLOG DEBUG : "******* JoinRoomReply not implemented *****\n" ELOG;
           exit 1
       
       end
@@ -461,7 +470,7 @@
           { id = id; words = s }
         
         let print t =
-          lprintf "SEARCH %d FOR %s\n" t.id t.words
+          BLOG DEBUG : "SEARCH %d FOR %s\n" (t.id) (t.words) ELOG
           
         let write buf t =
           buf_int buf t.id;
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/utils/net/anyEndian.ml ./src/utils/net/anyEndian.ml
--- ./src/utils/net/anyEndian.ml	2004-03-07 10:34:28.000000000 +0100
+++ ./src/utils/net/anyEndian.ml	2004-05-31 18:00:48.000000000 +0200
@@ -78,8 +78,7 @@
 let get_md4 s pos =
   try Md4.direct_of_string (String.sub s pos 16)  
   with e ->
-    lprintf "exception in get_md4 %d s=%s" pos (String.escaped s); 
-    lprint_newline ();
+    BLOG DEBUG : "exception in get_md4 %d s=%s\n" (pos) (String.escaped s) ELOG;
     raise e
 
       
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/utils/net/http_client.ml ./src/utils/net/http_client.ml
--- ./src/utils/net/http_client.ml	2004-03-07 10:34:28.000000000 +0100
+++ ./src/utils/net/http_client.ml	2004-05-31 18:00:43.000000000 +0200
@@ -321,12 +321,12 @@
           end
           
     | 404 ->
-        lprintf "Http_client 404: Not found %s\n" (Url.to_string_no_args r.req_url);
+        BLOG WARN : "Http_client 404: Not found %s\n" (Url.to_string_no_args r.req_url) ELOG;
         close sock (Closed_for_error "bad reply");
         raise Not_found
           
     | _ ->
-        lprintf "Http_client: bad reply %d\n" ans_code;
+        BLOG WARN : "Http_client: bad reply %d\n" (ans_code) ELOG;
         close sock (Closed_for_error "bad reply");
         raise Not_found
 
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/utils/net/http_server.ml ./src/utils/net/http_server.ml
--- ./src/utils/net/http_server.ml	2004-03-18 00:42:32.000000000 +0100
+++ ./src/utils/net/http_server.ml	2004-05-31 18:00:46.000000000 +0200
@@ -777,8 +777,8 @@
   try
     iter new_pos
   with e ->
-      lprintf "HTTPSERVER: Exception %s in request_handler\n"
-        (Printexc2.to_string e);
+      BLOG DEBUG : "HTTPSERVER: Exception %s in request_handler\n"
+        (Printexc2.to_string e) ELOG;
       close sock (Closed_for_exception e)
 
 let request_closer sock msg = 
@@ -798,7 +798,7 @@
         TcpBufferedSocket.set_closer sock request_closer;
         TcpBufferedSocket.set_handler sock TcpBufferedSocket.BUFFER_OVERFLOW
           (fun _ -> TcpBufferedSocket.close sock Closed_for_overflow;
-	       lprintf "BUFFER OVERFLOW\n" );  ()
+	       BLOG DEBUG : "BUFFER OVERFLOW\n" ELOG);  ()
       else
         Unix.close s
   | _ -> ()
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/utils/net/ip_set.ml ./src/utils/net/ip_set.ml
--- ./src/utils/net/ip_set.ml	2004-03-08 00:02:31.000000000 +0100
+++ ./src/utils/net/ip_set.ml	2004-05-31 18:00:52.000000000 +0200
@@ -94,14 +94,13 @@
 	  end else 
 	    raise Not_found
 	with _ ->
-	  lprintf "Syntax error: %s" line;
-	  lprint_newline ()
+	  BLOG DEBUG : "Syntax error: %s\n" (line) ELOG;
+	  ()
     done;
     bl_empty (* not reached *)
   with End_of_file ->
     close_in cin;
-    lprintf "IP blacklist: %d ranges loaded" !nranges;
-    lprint_newline ();
+    BLOG INFO : "IP blacklist: %d ranges loaded\n" (!nranges) ELOG;
     !bl
 
 let load filename =
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/utils/net/tcpBufferedSocket.ml ./src/utils/net/tcpBufferedSocket.ml
--- ./src/utils/net/tcpBufferedSocket.ml	2004-05-05 22:55:37.000000000 +0200
+++ ./src/utils/net/tcpBufferedSocket.ml	2004-05-31 18:00:48.000000000 +0200
@@ -389,14 +389,16 @@
       end
     else
     if b.len + len > b.max_buf_size then begin
-        lprintf "BUFFER OVERFLOW %d+%d> %d\n" b.len len b.max_buf_size ;
+	BLOG DEBUG #
+        BLOG DEBUG : "BUFFER OVERFLOW %d+%d> %d\n" (b.len) (len) (b.max_buf_size) ELOG;
 
-        lprintf "MESSAGE [";
+        BLOG DEBUG : "MESSAGE [" ELOG;
         for i = pos1 to pos1 + (mini len 20) - 1 do
-          lprintf "(%d)" (int_of_char s.[i]);
+          ldebug "(%d)" (int_of_char s.[i]);
         done;
-        if len > 20 then lprintf "...";
-        lprintf "]\n";
+        if len > 20 then ldebug "...";
+        BLOG DEBUG : "]\n" ELOG
+	ELOG;
 
         t.event_handler t BUFFER_OVERFLOW;
       end
@@ -1318,12 +1320,11 @@
         forecast_upload t 0;    (* The TCP ACK packet *)
         t
     | e ->
-        lprintf "For host %s port %d\n" (Unix.string_of_inet_addr host)
-        port;
+        BLOG DEBUG : "For host %s port %d\n" (Unix.string_of_inet_addr host) (port) ELOG;
         close t Closed_connect_failed;
         raise e
   with e ->
-      lprintf "+++ Exception BEFORE CONNECT %s\n" (Printexc2.to_string e);
+      BLOG DEBUG : "+++ Exception BEFORE CONNECT %s\n" (Printexc2.to_string e) ELOG;
       raise e
       
 
diff -x Root -x Repository -x Entries -x '*.orig' -u -N -r ./src/utils/net/tcpClientSocket.ml ./src/utils/net/tcpClientSocket.ml
--- ./src/utils/net/tcpClientSocket.ml	2003-11-20 17:43:27.000000000 +0100
+++ ./src/utils/net/tcpClientSocket.ml	2004-05-31 18:00:48.000000000 +0200
@@ -605,13 +605,11 @@
     with 
       Unix.Unix_error((Unix.EINPROGRESS|Unix.EINTR),_,_) -> t
     | e -> 
-        lprintf "For host %s port %d" (Unix.string_of_inet_addr host)
-        port; lprint_newline ();
+        BLOG DEBUG : "For host %s port %d\n" (Unix.string_of_inet_addr host) (port) ELOG;
         close t "connect failed";
         raise e
   with e -> 
-      lprintf "+++ Exception BEFORE CONNECT %s" (Printexc2.to_string e);
-      lprint_newline ();
+      BLOG DEBUG : "+++ Exception BEFORE CONNECT %s\n" (Printexc2.to_string e) ELOG;
       raise e
       
   
