-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add levels to Trace_core
.
#29
Conversation
these levels are used to control the verbosity levels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add tests? I'm getting an error when I set the current log level to Info
in t1.ml
git diff
diff --git a/test/t1.ml b/test/t1.ml
index 87e4792..a4c6e32 100644
--- a/test/t1.ml
+++ b/test/t1.ml
@@ -1,6 +1,7 @@
let run () =
Trace.set_process_name "main";
Trace.set_thread_name "t1";
+ Trace.set_current_level Trace.Level.Info;
File "test/dune", line 3, characters 8-10:
3 | (name t1)
^^
trace-tef error: cannot find span -9223372036854775808
trace-tef error: cannot find span -92
Looks like it's trying to exit a span
that wasn't created due to check_level
being false
ocaml-trace/src/core/trace_core.ml
Lines 40 to 47 in e81650d
let[@inline] with_span ?level ?__FUNCTION__ ~__FILE__ ~__LINE__ ?data name f = | |
match A.get collector with | |
| Some collector when check_level ?level () -> | |
with_span_collector_ collector ?__FUNCTION__ ~__FILE__ ~__LINE__ ?data name | |
f | |
| _ -> | |
(* fast path: no collector, no span *) | |
f Collector.dummy_span |
I wonder how it will behave with Trace.with_span ~level:Trace.Level.Trace "main" @@ fun span ->
Trace.message ~level:Trace.Level.Info ~span "world"; I'm not sure exactly how |
Indeed, the span won't exist, so depending on the backend, the message would attach to the closest span with level <= |
Thanks a lot for finding the bug in t1.ml btw, I just fixed it. |
these levels are used to control the verbosity levels.