@@ -138,9 +138,6 @@ struct
138138 severity : Severity .t ;
139139 multipiece : MultiPiece .t ;
140140 } [@@ deriving eq , ord , hash , yojson ]
141-
142- let should_warn {tags; severity; _} =
143- Tags. should_warn tags && Severity. should_warn severity
144141end
145142
146143module Table =
@@ -236,11 +233,9 @@ let print ?(ppf= !formatter) (m: Message.t) =
236233
237234
238235let add m =
239- if ! GU. should_warn then (
240- if Message. should_warn m && not (Table. mem m) then (
241- print m;
242- Table. add m
243- )
236+ if not (Table. mem m) then (
237+ print m;
238+ Table. add m
244239 )
245240
246241
@@ -253,33 +248,45 @@ let msg_context () =
253248 None (* avoid identical messages from multiple contexts without any mention of context *)
254249
255250let msg severity ?loc ?(tags =[] ) ?(category =Category. Unknown ) fmt =
256- let finish doc =
257- let text = Pretty. sprint ~width: max_int doc in
258- let loc = match loc with
259- | Some node -> Some node
260- | None -> Option. map (fun node -> Location. Node node) ! Node0. current_node
251+ if ! GU. should_warn && Severity. should_warn severity && (Category. should_warn category || Tags. should_warn tags) then (
252+ let finish doc =
253+ let text = Pretty. sprint ~width: max_int doc in
254+ let loc = match loc with
255+ | Some node -> Some node
256+ | None -> Option. map (fun node -> Location. Node node) ! Node0. current_node
257+ in
258+ add {tags = Category category :: tags ; severity; multipiece = Single {loc; text; context = msg_context () }}
261259 in
262- add {tags = Category category :: tags ; severity; multipiece = Single {loc; text; context = msg_context () }}
263- in
264- Pretty. gprintf finish fmt
260+ Pretty. gprintf finish fmt
261+ )
262+ else
263+ Tracing. mygprintf fmt
265264
266265let msg_noloc severity ?(tags =[] ) ?(category =Category. Unknown ) fmt =
267- let finish doc =
268- let text = Pretty. sprint ~width: max_int doc in
269- add {tags = Category category :: tags ; severity; multipiece = Single {loc = None ; text; context = msg_context () }}
270- in
271- Pretty. gprintf finish fmt
266+ if ! GU. should_warn && Severity. should_warn severity && (Category. should_warn category || Tags. should_warn tags) then (
267+ let finish doc =
268+ let text = Pretty. sprint ~width: max_int doc in
269+ add {tags = Category category :: tags ; severity; multipiece = Single {loc = None ; text; context = msg_context () }}
270+ in
271+ Pretty. gprintf finish fmt
272+ )
273+ else
274+ Tracing. mygprintf fmt
272275
273276let msg_group severity ?(tags =[] ) ?(category =Category. Unknown ) fmt =
274- let finish doc msgs =
275- let group_text = Pretty. sprint ~width: max_int doc in
276- let piece_of_msg (doc , loc ) =
277- let text = Pretty. sprint ~width: max_int doc in
278- Piece. {loc; text; context = None }
277+ if ! GU. should_warn && Severity. should_warn severity && (Category. should_warn category || Tags. should_warn tags) then (
278+ let finish doc msgs =
279+ let group_text = Pretty. sprint ~width: max_int doc in
280+ let piece_of_msg (doc , loc ) =
281+ let text = Pretty. sprint ~width: max_int doc in
282+ Piece. {loc; text; context = None }
283+ in
284+ add {tags = Category category :: tags ; severity; multipiece = Group {group_text; pieces = List. map piece_of_msg msgs}}
279285 in
280- add {tags = Category category :: tags ; severity; multipiece = Group {group_text; pieces = List. map piece_of_msg msgs}}
281- in
282- Pretty. gprintf finish fmt
286+ Pretty. gprintf finish fmt
287+ )
288+ else
289+ Tracing. mygprintf fmt
283290
284291(* must eta-expand to get proper (non-weak) polymorphism for format *)
285292let warn ?loc = msg Warning ?loc
0 commit comments