From: james woodyatt <jhw@wetware.com>
To: The Caml Trade <caml-list@inria.fr>
Subject: Re: [Caml-list] kprintf with user formatters
Date: Fri, 16 Jul 2004 09:17:08 -0700 [thread overview]
Message-ID: <95E82B54-D743-11D8-87CB-000A958FF2FE@wetware.com> (raw)
In-Reply-To: <20040715001758.GF26614@fichte.ai.univie.ac.at>
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 <jhw@wetware.com>
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
prev parent reply other threads:[~2004-07-16 16:17 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-30 16:32 Damien
2004-07-14 21:10 ` Pierre Weis
2004-07-15 0:17 ` Markus Mottl
2004-07-15 7:30 ` David MENTRE
2004-07-15 7:59 ` Jean-Christophe Filliatre
2004-07-15 23:35 ` henri dubois-ferriere
2004-07-15 7:39 ` Damien
2004-07-15 12:19 ` Markus Mottl
2004-07-15 12:42 ` Basile Starynkevitch [local]
2004-07-15 13:45 ` Markus Mottl
2004-07-15 14:22 ` Basile Starynkevitch [local]
2004-07-15 14:57 ` Markus Mottl
2004-07-16 6:47 ` Pierre Weis
2004-07-16 7:13 ` Jean-Christophe Filliatre
2004-07-16 7:23 ` henri dubois-ferriere
2004-07-16 7:44 ` Jean-Christophe Filliatre
2004-07-16 17:56 ` Markus Mottl
2004-07-19 9:17 ` Pierre Weis
2004-07-19 9:32 ` Jean-Christophe Filliatre
2004-07-16 7:21 ` henri dubois-ferriere
2004-07-16 17:44 ` Markus Mottl
2004-07-19 10:10 ` Pierre Weis
2004-07-19 10:43 ` Jon Harrop
2004-07-21 15:52 ` Pierre Weis
2004-07-21 17:43 ` lazyness in ocaml (was : [Caml-list] kprintf with user formatters) Daniel Bünzli
2004-07-22 16:28 ` Pierre Weis
2004-07-22 17:03 ` William Lovas
2004-07-22 23:00 ` skaller
2004-07-23 3:32 ` William Lovas
2004-07-28 7:26 ` Pierre Weis
2004-07-28 8:06 ` skaller
2004-07-28 8:29 ` Daniel Bünzli
2004-07-28 9:13 ` Pierre Weis
2004-07-28 9:36 ` skaller
2004-07-28 9:38 ` skaller
2004-07-28 10:17 ` Jason Smith
2004-07-28 12:31 ` skaller
2004-07-21 20:41 ` [Caml-list] kprintf with user formatters Jon Harrop
2004-07-22 15:39 ` Pierre Weis
2004-07-22 22:16 ` [Caml-list] lazy evaluation: [Was: kprintf with user formatters] skaller
2004-07-22 22:42 ` [Caml-list] kprintf with user formatters skaller
2004-07-22 8:05 ` [Caml-list] wait instruction lehalle@miriad
2004-07-22 8:40 ` Olivier Andrieu
2004-07-22 10:35 ` lehalle@miriad
2004-07-22 10:33 ` Vitaly Lugovsky
2004-07-16 6:17 ` [Caml-list] kprintf with user formatters Pierre Weis
2004-07-16 17:14 ` Markus Mottl
2004-07-19 10:00 ` Pierre Weis
2004-07-16 6:02 ` Pierre Weis
2004-07-16 8:42 ` Damien
2004-07-19 9:00 ` Pierre Weis
2004-07-16 16:52 ` Markus Mottl
2004-07-19 9:28 ` Pierre Weis
2004-07-15 22:20 ` Pierre Weis
2004-07-15 23:01 ` Markus Mottl
2004-07-16 16:17 ` james woodyatt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=95E82B54-D743-11D8-87CB-000A958FF2FE@wetware.com \
--to=jhw@wetware.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox