From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA27198; Fri, 16 Jul 2004 18:17:07 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA26912 for ; Fri, 16 Jul 2004 18:17:06 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from wetware.com (wetware.wetware.com [199.108.16.1]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i6GGH4SH027571 for ; Fri, 16 Jul 2004 18:17:05 +0200 Received: from [199.108.16.74] (helo=[199.108.16.74]) by wetware.com with esmtp (Exim 4.20) id 1BlVOQ-0004JU-4A for caml-list@inria.fr; Fri, 16 Jul 2004 09:17:02 -0700 Mime-Version: 1.0 (Apple Message framework v618) In-Reply-To: <20040715001758.GF26614@fichte.ai.univie.ac.at> References: <20040630183237.457317c7@mostha> <200407142110.XAA25344@pauillac.inria.fr> <20040715001758.GF26614@fichte.ai.univie.ac.at> Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <95E82B54-D743-11D8-87CB-000A958FF2FE@wetware.com> Content-Transfer-Encoding: 7bit From: james woodyatt Subject: Re: [Caml-list] kprintf with user formatters Date: Fri, 16 Jul 2004 09:17:08 -0700 To: The Caml Trade X-Mailer: Apple Mail (2.618) X-Miltered: at concorde with ID 40F7FF80.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; woodyatt:01 jhw:01 wetware:01 caml-list:01 kprintf:01 formatters:01 pierre:01 weis:01 printf:01 fmt:01 fmt:01 printf:01 ips:99 stdout:01 stdout:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On 14 Jul 2004, at 17:17, Markus Mottl wrote: > On Wed, 14 Jul 2004, Pierre Weis wrote: >> Your problem is thus that the function Debug.printf is not the right >> one (since it has not the right type :) > > Btw., since we are at it: I'd like to use my own printers depending on > a conditional, e.g.: > > let log level fmt = > if may_log level then > kfprintf ... > else > ??? > > If the given log level "level" does not allow logging the message > specified by "fmt", I just want to ignore the parameters provided > together > with "fmt" - but how? Is there some (safe) trick, or do I have to > write > my own Printf/Format-modules? I don't want to waste computation time > by unnecessarily converting format arguments to strings, which may be > very costly, e.g. when this would mean converting IPs to hostnames, > etc. The next release of my [Cf] library (due probably sometime this weekend) contains the foundation of a flexible diagnostic event journaling system, which is inspired by Log4j and various other similar systems. Using just the interface I'm almost ready to release now, the code would look like this: module J = Cf_journal if J.stdout#enabled `Info then J.stdout#info "this is an informational message (x=%d) x Note: because I plan to build this out to look a lot like Log4j, the format and its associated arguments are used to construct an event object and the event is sent to visit a list of archivers, each of which makes its own decision about how to write the events into their respective repositories. The [#enabled] method can be used to short-cut the call to [kprintf] embedded in the journal agent's logging methods. The example above is an example of using the built-in [stdout] basic agent, but that's a trivial example. For debugging messages, I simply made the [#debug] method return [true] so that it will be easily used inside [assert] expressions, like so: assert (J.stdout#debug "this is a debug message (x=%d)" x) I know this isn't what you want, but I don't see how there is a good way to get what you want. I generally like the idea of using the -noassert compile time option to decide whether to include the code for generating console debugging logs. -- j h woodyatt markets are only free to the people who own them. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners