capitalization of files; add new Log

This commit is contained in:
Simon Cruanes 2017-12-28 14:03:23 +01:00
parent bed469c0cf
commit fc5a2d4e9d
30 changed files with 53 additions and 47 deletions

33
src/core/Log.ml Normal file
View file

@ -0,0 +1,33 @@
(*
MSAT is free software, using the Apache license, see file LICENSE
Copyright 2014 Guillaume Bury
Copyright 2014 Simon Cruanes
*)
(** {1 Logging functions, real version} *)
let enabled = true (* NOTE: change here for 0-overhead *)
let debug_level_ = ref 0
let set_debug l = debug_level_ := l
let get_debug () = !debug_level_
let debug_fmt_ = ref Format.err_formatter
let set_debug_out f = debug_fmt_ := f
(* does the printing, inconditionally *)
let debug_real_ l k =
k (fun fmt ->
Format.fprintf !debug_fmt_ "@[<2>@{<Blue>[%d|%.3f]@}@ "
l (Sys.time());
Format.kfprintf
(fun fmt -> Format.fprintf fmt "@]@.")
!debug_fmt_ fmt)
let[@inline] debugf l k =
if enabled && l <= !debug_level_ then (
debug_real_ l k;
)
let[@inline] debug l msg = debugf l (fun k->k "%s" msg)

View file

@ -6,13 +6,14 @@ Copyright 2014 Simon Cruanes
(** {1 Logging function, for debugging} *)
val enabled : bool
val set_debug : int -> unit (** Set debug level *)
val get_debug : unit -> int (** Current debug level *)
val debugf :
int ->
('a, Format.formatter, unit, unit) format4 ->
('a -> unit) ->
((('a, Format.formatter, unit, unit) format4 -> 'a) -> unit) ->
unit
(** Emit a debug message at the given level. If the level is lower
than [get_debug ()], the message will indeed be emitted *)

15
src/core/jbuild Normal file
View file

@ -0,0 +1,15 @@
; vim:ft=lisp:
(jbuild_version 1)
; main binary
(library
((name msat)
(public_name msat)
(synopsis "core data structures and algorithms for msat")
(libraries ())
(flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -color always -safe-string))
(ocamlopt_flags (:standard -O3 -bin-annot
-unbox-closures -unbox-closures-factor 20))
))

View file

@ -1 +0,0 @@
log_real.ml

View file

@ -1,18 +0,0 @@
(*
MSAT is free software, using the Apache license, see file LICENSE
Copyright 2014 Guillaume Bury
Copyright 2014 Simon Cruanes
*)
(** {1 Logging functions, dummy version}
This does nothing. *)
let debug_level_ = ref 0
let set_debug l = debug_level_ := l
let get_debug () = !debug_level_
let debugf _ _ _ = ()
let debug _ _ = ()
let set_debug_out _ = ()

View file

@ -1,24 +0,0 @@
(*
MSAT is free software, using the Apache license, see file LICENSE
Copyright 2014 Guillaume Bury
Copyright 2014 Simon Cruanes
*)
(** {1 Logging functions, real version} *)
let debug_level_ = ref 0
let set_debug l = debug_level_ := l
let get_debug () = !debug_level_
let debug_fmt_ = ref Format.err_formatter
let set_debug_out f = debug_fmt_ := f
let debugf l format k =
if l <= !debug_level_
then
k (Format.kfprintf
(fun fmt -> Format.fprintf fmt "@]@.")
!debug_fmt_ format)
let debug l msg = debugf l "%s" (fun k->k msg)