Skip to content

Commit 7d9a997

Browse files
committed
fully use logger for config printing
1 parent 3b46043 commit 7d9a997

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

lib/rule.ml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,20 @@ module Prefix = struct
6565
|> Option.map ~f:(fun (res : prefix_rule * int) -> (fst res).channel_name)
6666

6767
let print_prefix_routing rules =
68+
let log = Devkit.Log.from "context" in
6869
let show_match l = String.concat ~sep:" or " @@ List.map ~f:(fun s -> s ^ "*") l in
6970
rules
7071
|> List.iter ~f:(fun (rule : prefix_rule) ->
7172
begin
7273
match rule.allow, rule.ignore with
73-
| None, None -> Stdio.printf " any"
74-
| None, Some [] -> Stdio.printf " any"
75-
| None, Some l -> Stdio.printf " not %s" (show_match l)
76-
| Some l, None -> Stdio.printf " %s" (show_match l)
77-
| Some l, Some [] -> Stdio.printf " %s" (show_match l)
78-
| Some l, Some i -> Stdio.printf " %s and not %s" (show_match l) (show_match i)
74+
| None, None -> log#info " any"
75+
| None, Some [] -> log#info " any"
76+
| None, Some l -> log#info " not %s" (show_match l)
77+
| Some l, None -> log#info " %s" (show_match l)
78+
| Some l, Some [] -> log#info " %s" (show_match l)
79+
| Some l, Some i -> log#info " %s and not %s" (show_match l) (show_match i)
7980
end;
80-
Stdio.printf " -> #%s\n%!" rule.channel_name)
81+
log#info " -> #%s\n%!" rule.channel_name)
8182
end
8283

8384
module Label = struct
@@ -100,17 +101,18 @@ module Label = struct
100101
rules |> List.filter_map ~f:match_rule |> List.dedup_and_sort ~compare:String.compare
101102

102103
let print_label_routing rules =
104+
let log = Devkit.Log.from "context" in
103105
let show_match l = String.concat ~sep:" or " l in
104106
rules
105107
|> List.iter ~f:(fun (rule : label_rule) ->
106108
begin
107109
match rule.allow, rule.ignore with
108-
| None, None -> Stdio.printf " any"
109-
| None, Some [] -> Stdio.printf " any"
110-
| None, Some l -> Stdio.printf " not %s" (show_match l)
111-
| Some l, None -> Stdio.printf " %s" (show_match l)
112-
| Some l, Some [] -> Stdio.printf " %s" (show_match l)
113-
| Some l, Some i -> Stdio.printf " %s and not %s" (show_match l) (show_match i)
110+
| None, None -> log#info " any"
111+
| None, Some [] -> log#info " any"
112+
| None, Some l -> log#info " not %s" (show_match l)
113+
| Some l, None -> log#info " %s" (show_match l)
114+
| Some l, Some [] -> log#info " %s" (show_match l)
115+
| Some l, Some i -> log#info " %s and not %s" (show_match l) (show_match i)
114116
end;
115-
Stdio.printf " -> #%s\n%!" rule.channel_name)
117+
log#info " -> #%s\n%!" rule.channel_name)
116118
end

0 commit comments

Comments
 (0)