File: fcl_debug.ml

package info (click to toggle)
facile 1.1.4-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 716 kB
  • sloc: ml: 6,862; makefile: 90
file content (23 lines) | stat: -rw-r--r-- 1,270 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(***********************************************************************)
(*                                                                     *)
(*                           FaCiLe                                    *)
(*                 A Functional Constraint Library                     *)
(*                                                                     *)
(*            Nicolas Barnier, Pascal Brisset, LOG, CENA               *)
(*                                                                     *)
(* Copyright 2004 CENA. All rights reserved. This file is distributed  *)
(* under the terms of the GNU Lesser General Public License.           *)
(***********************************************************************)
let level = ref (try Sys.getenv "FACILEDEBUG" with Not_found -> "");;
let log = ref stdout;;
let call lev f =
  assert(if !level = "*" || String.contains !level lev then begin f !log ;flush !log end; true);;

let internal_error mesg =
  failwith (Printf.sprintf "Internal error (%s). Please send a bug report to facile@recherche.enac.fr" mesg)

let fatal_error mesg =
  failwith (Printf.sprintf "Fatal error: %s" mesg)

let print_in_assert pred mesg =
  pred || (Printf.fprintf stderr "Fatal error: %s" mesg; flush stderr; false)