In order to provide users and developpers with a useful log file you have the possibility to organize information logging per level. Those levels are 'debug', 'info', 'warn', 'error' and 'fatal'. They are organized as follow debug < info < warn < error < fatal. So while hacking mldonkey you'll have to explicitly classify the information you want to log. Here's some suggestions to help you correctly sort your messages. * In 'debug' you can put messages to help you debug/check mldonkey behavior. Users are not supposed to see this level of log. * In 'info' you can put messages to give a positive feedback of what is doing mldonkey * In 'warn' you can put messages to warn the user that mldonkey is doing something different than he could have expected. * In 'error' you can put messages to alert the user that something is seriously wrong in mldonkey. * In 'fatal' you can put messages announcing the end of the world. The user will then have the possibility to choose his level of logging. The recommended level for users is 'info'. In this case all messages of level >= info (info, warn, fatal, error) will be logged. This choice can happen at compile time or at execution time. At compilation time, all logging function below the choosed level will be stripped from code. This will save them at least one test of level per stripped logging message (if level<'info' then do_nothing). The choice of levels at compile time is 'nolog', 'extra', 'debug', 'info', 'warn', 'error' and 'fatal'. No log will strip all messages from the program while extra will append the name of file and the line in which the message is thrown. To enable the elimination of some level of messages at compile time you _must_ use some macros, i know it's a bit restrictive but users will have the benefit of a faster program. They will also be able to discriminate from a normal and an anormal behavior of mldonkey and to avoid filling a bug report because of a debug message. In order to clarify the resulting log, the level of messages will be appended through macros at compile time. Here they are : BLOG level {(cond)} [:|#] * ELOG This should be read as 'BLOG' : begin log 'level' : level of the message in DEBUG, INFO, WARN, ERROR, FATAL '(cond)' : is an optional condition. If cond is true then the message will be logged. ':' or '#' : what you can use in '*' will depend of this sign ELOG : end log. * if you use ':' above '*' _must_ be : fmt varargs which is the typical use of Printf.printf in ocaml : fmt is the string describing the format of the message and varargs are the arguments of this message. * if you use '#' above '*' _must_ be a simple bloc of normal ocaml expressions. /!\ These macros should be considered as normal expressions in ocaml so the rule to put ';' or not is the same as ocaml. I strongly suggest to always put your code in a begin end bloc when using the '#' macro ( BLOG DEBUG # begin * end). If you use these macros your message will be added to its level in the log file like this : BLOG FATAL : "My message\n" ELOG; ---log file------- FATAL : My message ------------------ BLOG ERROR : "My message\n" ELOG; ---log file------- ERROR : My message ------------------ ... The debug level is a bit different when you build mldonkey with the 'extra' level (otherwise it's like the others): ---log file------- DEBUG in file.ml line 4 : My message ------------------ If you don't want to use these macros you can use some functions in src/utils/cdk/printf2.ml to classify your messages : ldebug, linfo, lwarn, lerror, lfatal. /!\ Remember that the level is prepended to messages at compile time, so you will have to manually prepend the level of your message (following the same rule as describe above to sort your log file easily through grep and other common tools). =============================================================== *************************************************************** =============================================================== Examples (from commonGlobals.ml): A) -------------------------------------------------------------- BLOG DEBUG : "Exception %s while starting %s\n" server_name (Printexc2.to_string e) ELOG; -------------------------------------------------------------- It will be preprocessed as : Printf2.ldebug "Exception %s while starting %s\n" server_name (Printexc2.to_string e); and will print : DEBUG : Exception {e} while starting {server_name} B) -------------------------------------------------------------- BLOG WARN (port == (!!port_option) ) : "Can't listen on default port : trying another one...\n" ELOG; -------------------------------------------------------------- It will be preprocessed as if (port==(!!port_option)) then Printf2.lwarn "Can't listen on default port : trying another one...\n"; It will print (if port==!!port_option): WARN : Can't listen on default port : trying another one... C) -------------------------------------------------------------- BLOG ERROR # begin let m = "Oh my God! You killed Kenny!" in BLOG ERROR : "My message is : %s\n" m ELOG; end ELOG; -------------------------------------------------------------- It will be preprocessed as begin let m = "Oh my God! You killed Kenny!" in Printf2.lerror "My message is : %s\n" m; end;