Debian Codegraph @

ide/rocqide/minilib.ml

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 let rec print_list print fmt = function
12 | [] -> ()
13 | [x] -> print fmt x
14 | x :: r -> print fmt x; print_list print fmt r
15
16 type level = [
17 | `DEBUG
18 | `INFO
19 | `NOTICE
20 | `WARNING
21 | `ERROR
22 | `FATAL ]
23
24 (** Some excerpt of Util and similar files to avoid loading the whole
25 module and its dependencies (and hence Compat and Camlp5) *)
26
27 let debug = ref false
28
29 (* On a Win32 application with no console, writing to stderr raise
30 a Sys_error "bad file descriptor", hence the "try" below.
31 Ideally, we should re-route message to a log file somewhere, or
32 print in the response buffer.
33 *)
34
35 let log_pp ?(level = `DEBUG) msg =
36 let prefix = match level with
37 | `DEBUG -> "DEBUG"
38 | `INFO -> "INFO"
39 | `NOTICE -> "NOTICE"
40 | `WARNING -> "WARNING"
41 | `ERROR -> "ERROR"
42 | `FATAL -> "FATAL"
43 in
44 if !debug then begin
45 try Format.eprintf "[%s] @[%a@]\n%!" prefix Pp.pp_with msg
46 with _ -> ()
47 end
48
49 let log ?level str = log_pp ?level (Pp.str str)
50
51 let rocqify d = Filename.concat d "coq"
52
53 let rocqide_config_home () =
54 rocqify (Glib.get_user_config_dir ())
55
56 let rocqide_data_dirs () =
57 rocqify (Glib.get_user_data_dir ())
58 :: List.map rocqify (Glib.get_system_data_dirs ())
59 @ [Envars.datadir ()]
60
61 let rocqide_system_config_dirs () =
62 List.map rocqify (Glib.get_system_config_dirs ())
63
64 let rocqide_default_config_dir () =
65 Envars.configdir ()
66
67 let rocqide_config_dirs () =
68 rocqide_config_home () ::
69 rocqide_system_config_dirs () @
70 [rocqide_default_config_dir ()]