-DIRS = ocaml hbugs gTopLevel searchEngine mathql_test
+DIRS = ocaml hbugs gTopLevel searchEngine mathql_test hxp
DIRS_BYTE = $(patsubst %,%.byte,$(DIRS))
DIRS_OPT = $(patsubst %,%.opt,$(DIRS))
<section name="mathql_interpreter">
<key name="db_map">mathql_db_map.txt</key>
<key name="postgresql_connection_string">dbname=mowgli host=mowgli.cs.unibo.it user=helm password=awH21Un</key>
- <!-- flags is a string of the following characters: "S", "L", "W", "V" -->
- <!-- S logs statistical information (query execution times) -->
- <!-- L logs the low-level queries (in SQL) -->
- <!-- W logs some warnings (for mathql experts only) -->
- <!-- V logs the executed queries (in MathQL) -->
- <!-- By default the above information is not logged -->
+ <!-- flags is a string of the following characters: -->
+ <!-- "Q", "R", "S", "T", "W" -->
+ <!-- Q logs the low-level queries (in SQL) -->
+ <!-- R logs the result of the executed queries (in MathQL) -->
+ <!-- S logs the source of the executed queries (in MathQL) -->
+ <!-- T logs statistical information (query execution times) -->
+ <!-- W logs some warnings (for mathql experts only) -->
+ <!-- By default the above information is not logged -->
<key name="flags"></key>
</section>
<section name="local_library">
(* GLOBAL CONSTANTS *)
let mqi_debug_fun s = debug_print ~level:2 s
-let mqi_handle = MQIC.init mqi_debug_fun
+let mqi_handle = MQIC.init ~log:mqi_debug_fun ()
let xlinkns = Gdome.domString "http://www.w3.org/1999/xlink";;
broker_id :=
Some (Hbugs_tutors_common.register_to_broker
my_own_id my_own_url "FOO" "Search_pattern_apply tutor");
- let mqi_handle = MQIC.init prerr_string in
+ let mqi_handle = MQIC.init ~log:prerr_string () in
if Sys.file_exists environment_file then
restore_environment ();
Http_daemon.start'
let get_handle () =
C.init ~flags:(C.flags_of_string ! int_options)
- (fun s -> print_string s; flush stdout)
+ ~log:(fun s -> print_string s; flush stdout) ()
let issue handle q =
let mode = [Open_wronly; Open_append; Open_creat; Open_text] in
let ich = Lexing.from_channel stdin in
let flags = if Array.length Sys.argv >= 2 then Sys.argv.(1) else "" in
let log s = print_string s; flush stdout in
- let handle = C.init ~flags:(C.flags_of_string flags) log in
+ let handle = C.init ~flags:(C.flags_of_string flags) ~log:log () in
if not (C.connected handle) then begin
print_endline "mqitop: no connection"; flush stdout
end;
(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
*)
-type flag = Postgres | Galax | Stat | Quiet | Warn | Log | Source
+type flag = Galax | Postgres | Queries | Result | Source | Times | Warn
type handle = {
log : string -> unit; (* logging function *)
let flags handle = handle.set
let string_of_flag = function
- | Postgres -> "P"
| Galax -> "G"
- | Stat -> "S"
- | Quiet -> "Q"
+ | Postgres -> "P"
+ | Queries -> "Q"
+ | Result -> "R"
+ | Source -> "S"
+ | Times -> "T"
| Warn -> "W"
- | Log -> "L"
- | Source -> "V"
let flag_of_char = function
- | 'P' -> [Postgres]
| 'G' -> [Galax]
- | 'S' -> [Stat]
- | 'Q' -> [Quiet]
+ | 'P' -> [Postgres]
+ | 'Q' -> [Queries]
+ | 'R' -> [Result]
+ | 'S' -> [Source]
+ | 'T' -> [Times]
| 'W' -> [Warn]
- | 'L' -> [Log]
- | 'V' -> [Source]
| _ -> []
let string_fold_left f a s =
let flags_of_string s =
string_fold_left (fun l c -> l @ flag_of_char c) [] s
-let init ?(flags = []) mylog =
+let init ?(flags = []) ?(log = ignore) () =
let flags =
if flags = [] then
flags_of_string (Helm_registry.get "mathql_interpreter.flags")
then MQIMap.empty_map else MQIMap.read_map
in g ()
in
- {log = mylog; set = flags;
+ {log = log; set = flags;
pgc =
if List.mem Galax flags then
None
let connected handle =
if set handle Galax then false else (pgc handle) <> None
-let init_if_connected ?(flags = []) mylog =
- let handle = init ~flags:flags mylog in
+let init_if_connected ?(flags = []) ?(log = ignore) () =
+ let handle = init ~flags:flags ~log:log () in
ignore (pgc handle); handle
-
(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
*)
-type flag = Postgres | Galax | Stat | Quiet | Warn | Log | Source
+type flag = Galax | Postgres | Queries | Result | Source | Times | Warn
val string_of_flags : flag list -> string
val flags_of_string : string -> flag list
type handle
-val init : ?flags:(flag list) -> (string -> unit) -> handle
+val init : ?flags:(flag list) -> ?log:(string -> unit) -> unit -> handle
val close : handle -> unit
val connected : handle -> bool
-val init_if_connected : ?flags:(flag list) -> (string -> unit) -> handle
+val init_if_connected : ?flags:(flag list) -> ?log:(string -> unit) -> unit -> handle
(* The following functions allow to read the handle internal fields.
* For exclusive use of the interpreter.
let pg_query h table cols ct cfl =
let exec q =
- if C.set h C.Log then C.log h (q ^ "\n");
+ if C.set h C.Queries then C.log h (q ^ "\n");
P.exec (C.pgc h) q
in
let rec iter f sep = function
let t = P.start_time () in
P.text_of_query (C.log h) "\n" x;
let s = P.stop_time t in
- if C.set h C.Stat then
+ if C.set h C.Times then
C.log h (Printf.sprintf "Log source: %s\n" s);
eval_query c x
end else begin
let t = P.start_time () in
P.text_of_result (C.log h) "\n" s;
let r = P.stop_time t in
- if C.set h C.Stat then
+ if C.set h C.Times then
C.log h (Printf.sprintf "Log: %s\n" r);
s
end
let t = P.start_time () in
let r = MQIProperty.exec h q1 subj cons_true cons_false exp in
let s = P.stop_time t in
- if C.set h C.Stat then
+ if C.set h C.Times then
C.log h (Printf.sprintf "Property: %s,%i\n" s (List.length r));
r
| M.StatQuery x ->
let t = P.start_time () in
if C.set h C.Source then P.text_of_query (C.log h) "\n" x;
let r = eval_query c x in
+ if C.set h C.Result then P.text_of_result (C.log h) "\n" r;
let s = P.stop_time t in
- if C.set h C.Stat then
+ if C.set h C.Times then
C.log h (Printf.sprintf "MQIExecute: %s,%s\n" s
(C.string_of_flags (C.flags h)));
r
printf "HTML directory is %s\n" pages_dir;
flush stdout;
Unix.putenv "http_proxy" "";
-let mqi_handle = C.init debug_print in
+let mqi_handle = C.init ~log:debug_print () in
Http_daemon.start' ~port (callback mqi_handle);
C.close mqi_handle;
printf "%s is terminating, bye!\n" daemon_name