compat OCaml 4.12

This commit is contained in:
Simon Cruanes 2025-04-09 10:35:11 -04:00
parent 71dc18c00a
commit cdab1c0956
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -6,6 +6,9 @@ module A = Trace_core.Internal_.Atomic_
let on_tracing_error = ref (fun s -> Printf.eprintf "trace-tef error: %s\n%!" s)
let[@inline] int64_of_trace_id_ (id : Trace_core.trace_id) : int64 =
Bytes.get_int64_le (Bytes.unsafe_of_string id) 0
module Mock_ = struct
let enabled = ref false
let now = ref 0
@ -147,7 +150,7 @@ module Writer = struct
emit_sep_and_start_ self;
Printf.bprintf self.buf
{json|{"pid":%d,"cat":"trace","id":%Ld,"tid": %d,"ts": %.2f,"name":%a,"ph":"%c"%a}|json}
self.pid (String.get_int64_le id 0) tid ts str_val name
self.pid (int64_of_trace_id_ id) tid ts str_val name
(match flavor with
| None | Some Async -> 'b'
| Some Sync -> 'B')
@ -160,7 +163,7 @@ module Writer = struct
emit_sep_and_start_ self;
Printf.bprintf self.buf
{json|{"pid":%d,"cat":"trace","id":%Ld,"tid": %d,"ts": %.2f,"name":%a,"ph":"%c"%a}|json}
self.pid (String.get_int64_le id 0) tid ts str_val name
self.pid (int64_of_trace_id_ id) tid ts str_val name
(match flavor with
| None | Some Async -> 'e'
| Some Sync -> 'E')