[Caml-list] Logging

1 view
Skip to first unread message

Tiago Antão

unread,
Jul 20, 2006, 5:23:38 AM7/20/06
to caml...@inria.fr
Hi!

Are there any best practices/libraries regarding logging in CAML? My
main use for it will be debugging (I know there are debugging
facilities in CAML, but I am very used to using log as a debug tool -
think Log4J for instance)...

Thanks a lot,
Tiago

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Matthieu Dubuget

unread,
Jul 20, 2006, 6:16:09 AM7/20/06
to caml...@inria.fr
Tiago Antão a écrit :

> Hi!
>
> Are there any best practices/libraries regarding logging in CAML? My
> main use for it will be debugging (I know there are debugging
> facilities in CAML, but I am very used to using log as a debug tool -
> think Log4J for instance)...
>
> Thanks a lot,
> Tiago
>
>

I do not know Log4J. For the same purpose as yours, I did a small Log
library, using another one, called Tics.

Tics is a binding to QueryPerformanceCouter and al. on MS Windows. At
this moment, it is not multiplatform, but this should be done very easily.

I need Tics because each message sent to Log is timestamped and stored
in memory. The user of Log then can flush and print or display the
stored message when possible.

I did this because I have plenty of memory for those tests, and I wanted
to avoid IO perturbations of timing. I also needed precise timing,
because I'm working with hardware.

Except from those constraint, I really don't think my tools are forth usi
ng.

Salutations

Matt

James Woodyatt

unread,
Jul 20, 2006, 3:31:22 PM7/20/06
to The Caml Trade
On Jul 20, 2006, at 2:20 AM, Tiago Antão wrote:
>
> Are there any best practices/libraries regarding logging in CAML? My
> main use for it will be debugging (I know there are debugging
> facilities in CAML, but I am very used to using log as a debug tool -
> think Log4J for instance)...

You may want to have a look at the Cf_journal module in my recently
released OCaml NAE Core Foundation library. See <http://sf.net/
projects/ocnae/> for downloads. It's not anywhere near as full-
featured as Log4J, but it was intended as a foundation upon which to
build something that full-featured.

I find it works pretty well for debugging purposes. Your mileage may

vary.



j h woodyatt <j...@conjury.org>


j h woodyatt <j...@conjury.org>

Jean-Christophe Filliatre

unread,
Jul 21, 2006, 5:02:55 AM7/21/06
to Tiago Antão, caml...@inria.fr

Tiago Antão writes:
>
> Are there any best practices/libraries regarding logging in CAML? My
> main use for it will be debugging (I know there are debugging
> facilities in CAML, but I am very used to using log as a debug tool -
> think Log4J for instance)...

I'm also using logging as a debug facility sometimes, and I use a
printf-like function for this purpose, as follows:

=========================
=========================
====================
let log_ch = open_out "logfile"
let log = Format.formatter_of_out_channel log_ch
let () = at_exit (fun () -> Format.pp_print_flush log (); close_out log
_ch)
let lprintf s = Format.fprintf log s
=========================
=========================
====================

which provides a function lprintf of type

=========================
=========================
====================
val lprintf : ('a, Format.formatter, unit) format -> 'a = <fun>
=========================
=========================
====================

to be used like Format.printf.

This is surely not the best way to do, and not very powerful, but at
least it is convenient to use when you already have Format-like
printers for your datatypes (using %a).

Hope this helps,
--
Jean-Christophe

Reply all
Reply to author
Forward
0 new messages