Skip to content

Commit 0ee0894

Browse files
FelixKrayerarkocal
authored andcommitted
Parallelism: Make messages thread-safe
fix printing issue by using BatFormat in messages.ml
1 parent abb1663 commit 0ee0894

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/common/util/messages.ml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ module Category = MessageCategory
88

99
open GobResult.Syntax
1010

11+
module Format = BatFormat
12+
1113

1214
module Severity =
1315
struct
@@ -195,10 +197,14 @@ let print ?(ppf= !formatter) (m: Message.t) =
195197
| Debug -> "white" (* non-bright white is actually some gray *)
196198
| Success -> "green"
197199
in
198-
let pp_prefix = Format.dprintf "@{<%s>[%a]%a@}" severity_stag Severity.pp m.severity Tags.pp m.tags in
200+
let pp_print_option ?(none = fun _ () -> ()) pp_v ppf = function
201+
| None -> none ppf ()
202+
| Some v -> pp_v ppf v
203+
in
204+
let pp_prefix = (fun ppf -> Format.fprintf ppf "@{<%s>[%a]%a@}" severity_stag Severity.pp m.severity Tags.pp m.tags) in
199205
let pp_loc ppf = Format.fprintf ppf " @{<violet>(%a)@}" CilType.Location.pp in
200206
let pp_loc ppf loc =
201-
Format.fprintf ppf "%a" (Format.pp_print_option pp_loc) (Option.map Location.to_cil loc)
207+
Format.fprintf ppf "%a" (pp_print_option pp_loc) (Option.map Location.to_cil loc)
202208
in
203209
let pp_piece ppf piece =
204210
Format.fprintf ppf "@{<%s>%s@}%a" severity_stag (Piece.text_with_context piece) pp_loc piece.loc
@@ -229,7 +235,7 @@ let print ?(ppf= !formatter) (m: Message.t) =
229235
let pp_quote ppf loc =
230236
if get_bool "warn.quote-code" then (
231237
let pp_cut_quote ppf = Format.fprintf ppf "@,@[<v 0>%a@,@]" pp_quote in
232-
(Format.pp_print_option pp_cut_quote) ppf (Option.map Location.to_cil loc)
238+
(pp_print_option pp_cut_quote) ppf (Option.map Location.to_cil loc)
233239
)
234240
in
235241
let pp_piece ppf piece = Format.fprintf ppf "%a%a" pp_piece piece pp_quote piece.loc in

0 commit comments

Comments
 (0)