Project

General

Profile

Download (3.27 KB) Statistics
| Branch: | Tag: | Revision:
1
(* This file is part of the Kind 2 model checker.
2

    
3
   Copyright (c) 2015 by the Board of Trustees of the University of Iowa
4

    
5
   Licensed under the Apache License, Version 2.0 (the "License"); you
6
   may not use this file except in compliance with the License.  You
7
   may obtain a copy of the License at
8

    
9
   http://www.apache.org/licenses/LICENSE-2.0 
10

    
11
   Unless required by applicable law or agreed to in writing, software
12
   distributed under the License is distributed on an "AS IS" BASIS,
13
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14
   implied. See the License for the specific language governing
15
   permissions and limitations under the License. 
16

    
17
*)
18

    
19
(** Logging and messaging *)
20

    
21
(** Every relevant event must be logged through the functions in this module
22
    but only for ingle-process mode. Use {! Event} for multi-process mode.
23

    
24
    @author Christoph Sticksel, Alain Mebsout
25
*)
26

    
27
module type Sig = sig
28

    
29
  type 'a log_printer =
30
    KindLib.log_level ->
31
    ('a, Format.formatter, unit, unit, unit, unit) format6 -> 'a
32
  
33
  type 'a m_log_printer =
34
    KindLib.kind_module -> 'a log_printer
35
  
36
  (** {1 Logging} *)
37

    
38
  (** Set module currently running *)
39
  val set_module : KindLib.kind_module -> unit 
40

    
41
  (** Get module currently running *)
42
  val get_module : unit -> KindLib.kind_module
43

    
44
  (** Format of log messages *)
45
  type log_format = 
46
    | F_pt    (** Plain text *)
47
    | F_xml   (** XML *)
48
    | F_json  (** JSON *)
49
    | F_relay (** Relayed *) 
50

    
51
  (** Returns the log format *)
52
  val get_log_format : unit -> log_format
53

    
54
  (** Chooses the log format *)
55
  val set_log_format : log_format -> unit
56

    
57
  (** Set log format to plain text *)
58
  val set_log_format_pt : unit -> unit
59

    
60
  (** Set log format to XML *)
61
  val set_log_format_xml : unit -> unit
62

    
63
  (** Set log format to JSON *)
64
  val set_log_format_json : unit -> unit
65

    
66
  (** Relay log messages to invariant manager, takes printing function as
67
      argument for relay messages. *)
68
  val set_relay_log : unit -> unit
69

    
70
  (** Cancel relaying of log messages *)
71
  val unset_relay_log : unit -> unit
72

    
73

    
74
  (** {1 Auxiliary functions} *)
75

    
76
  val pp_print_kind_module_xml_src : Format.formatter -> KindLib.kind_module -> unit
77

    
78
  val print_xml_trailer : unit -> unit
79

    
80
  val printf_xml : 'a m_log_printer
81

    
82
  val printf_json : 'a m_log_printer
83

    
84
  val parse_log_xml : KindLib.log_level -> KindLib.position -> string -> unit
85

    
86
  val parse_log_json : KindLib.log_level -> KindLib.position -> string -> unit
87

    
88
end
89

    
90
(** Logging functions accessible directly *)
91
include Sig
92

    
93
module type SLog = sig
94

    
95
  (** [log m l f v ...] outputs a message from module [m] on level [l],
96
      formatted with the parameterized string [f] and the values [v ...] *)
97
  val log : 'a log_printer
98

    
99
  (** [log_uncond m f v ...] outputs a message from module [m] unconditionally,
100
      formatted with the parameterized string [f] and the values [v ...] *)
101
  val log_uncond : ('a, Format.formatter, unit) format -> 'a
102

    
103
end
104

    
105

    
106
(** Create a logging module parameterized by a relay function *)
107
module Make (R : sig val printf_relay : 'a m_log_printer end) : SLog
108

    
109

    
110
(** One instance without relay is available directly *)
111
include SLog
112

    
113

    
114

    
115

    
116
(* 
117
   Local Variables:
118
   compile-command: "make -C .. -k"
119
   tuareg-interactive-program: "./kind2.top -I ./_build -I ./_build/SExpr"
120
   indent-tabs-mode: nil
121
   End: 
122
*)
(6-6/12)