feat: add trace prefix to options

This commit is contained in:
Leonardo de Moura 2019-10-22 14:43:02 -07:00
parent 3cd8dc6366
commit 13faf9fdf6
2 changed files with 7 additions and 6 deletions

View file

@ -96,7 +96,7 @@ do s ← getTraceState;
if !s.enabled then pure false
else do
opts ← getOptions;
pure $ opts.getBool cls
pure $ opts.getBool (`trace ++ cls)
@[inline] def disableTracing : m Unit :=
modifyTraceState $ fun s => { enabled := false, .. s }

View file

@ -14,19 +14,19 @@ instance : SimpleMonadTracerAdapter M :=
modify $ fun s => { traceState := f s.traceState, .. s } }
def tst1 : M Unit :=
do trace `trace.module (fun _ => ("hello" : MessageData));
trace `trace.module (fun _ => ("world" : MessageData));
do trace `module (fun _ => ("hello" : MessageData));
trace `module (fun _ => ("world" : MessageData));
pure ()
def tst2 (b : Bool) : M Unit :=
traceCtx `trace.module $ fun _ => do
traceCtx `module $ fun _ => do
tst1;
when b $ throw "error";
tst1;
pure ()
def tst3 (b : Bool) : M Unit :=
traceCtx `trace.module $ fun _ => do
traceCtx `module $ fun _ => do
tst2 b;
tst1
@ -41,7 +41,8 @@ match x.run opts {} with
| EState.Result.error _ s => do IO.println "Error"; displayTrace s
def main : IO Unit :=
do runM (tst3 true);
do IO.println "----";
runM (tst3 true);
IO.println "----";
runM (tst3 false)