(* 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
-