Question

I'm trying to use bolt (http://bolt.x9c.fr) to log my programs. My development environment consists of OCaml 4.0.1, Opam and Core on Mac OS X. Following Real World Ocaml, the compilation process is managed by corebuild.

Using corebuild to compile, Bolt does't produce any log. To make a simple test I used the example found in Bolt documentation.

This is simple test source:

let funct n =
  LOG "funct(%d)" n LEVEL DEBUG;
  for i = 1 to n do
    print_endline "..."
  done

let () =
  LOG "application start" LEVEL TRACE;
  funct 3;
  funct 7;
  LOG "application end" LEVEL TRACE

This is config file (bolt.config):

logger "" {
level = trace;
filter = all;
layout = default;
mode = direct;
output = file;
name = "log";
}

To run is necessary define the environment variable BOLT_CONFIG with the path to config file:

BOLT_CONFIG=./bolt.config

Compiling using:

ocamlc -c -I /Users/ivan/.opam/system/lib/bolt bolt.cma -pp 'camlp4o /Users/ivan/.opam/system/lib/bolt/bolt_pp.cmo' test.ml
ocamlc -o test.byte -I /Users/ivan/.opam/system/lib/bolt unix.cma dynlink.cma bolt.cma test.cmo

and run it's ok

but compiling with corebuild:

corebuild -pkgs Bolt -libs dynlink test.byte

the test runs but with no log. I think there is something in compilation parameters used by corebuild. Real World OCaml recommends the use of corebuild but now I think that Core parameters and Bolt are in some way "incompatible" or I'm forgetting something.

Was it helpful?

Solution

I've tried your test and it works for me, even with corebuild (but, are sure that Bolt should be written uppercased? In linux, it is not accepted). So, I would like to assure you, that the problem lies somewhere else.

There is no magic with corebuild, it just a thin wrapper around ocamlbuild:

cat `which corebuild`

so there shouldn't be any issues with it.

Make sure that yo're specifying an environment variable correctly. You should either specify it on each invocation, like this:

BOLT_CONFIG=./bolt.config corebuild -pkg bolt -libs dynlink test.byte --  

or you can just export it once:

export BOLT_CONFIG=./bolt.config

P.S. my configuration is:

OCaml 4.01.0 installed via opam 1.1
Linux Debian Squeeze
bolt 1.4
core 111.08.00
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top