refactor: use trace.subscriber instead of a separate library

This commit is contained in:
Simon Cruanes 2024-09-17 10:36:49 -04:00
parent cc6c311b45
commit 6920c3341a
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
14 changed files with 30 additions and 59 deletions

View file

@ -22,10 +22,10 @@ jobs:
- run: opam pin odoc 2.2.2 -y -n
# crash with 2.4, see https://github.com/ocaml/odoc/issues/1066
- name: Deps
run: opam install odig trace trace-tef trace-fuchsia trace-subscriber ppx_trace
run: opam install odig trace trace-tef trace-fuchsia ppx_trace
- name: Build
run: opam exec -- odig odoc --cache-dir=_doc/ trace trace-tef trace-fuchsia trace-subscriber ppx_trace
run: opam exec -- odig odoc --cache-dir=_doc/ trace trace-tef trace-fuchsia ppx_trace
- name: Deploy
uses: peaceiris/actions-gh-pages@v3

View file

@ -32,17 +32,17 @@ jobs:
dune-cache: true
allow-prerelease-opam: true
- run: opam install -t trace trace-subscriber trace-tef trace-fuchsia --deps-only
- run: opam install -t trace trace-tef trace-fuchsia --deps-only
- run: opam install ppx_trace --deps-only # no tests
if: matrix.ocaml-compiler != '4.08.x'
- run: opam exec -- dune build '@install' -p trace,trace-subscriber,trace-tef,trace-fuchsia
- run: opam exec -- dune build '@install' -p trace,trace-tef,trace-fuchsia
- run: opam exec -- dune build '@install' -p ppx_trace
if: matrix.ocaml-compiler != '4.08.x'
- run: opam exec -- dune runtest -p trace
- run: opam install trace
- run: opam exec -- dune runtest -p trace-subscriber,trace-tef,trace-fuchsia
- run: opam exec -- dune runtest -p trace-tef,trace-fuchsia
# with depopts
- run: opam install hmap
- run: opam exec -- dune build '@install' -p trace,trace-subscriber,trace-tef,trace-fuchsia
- run: opam install hmap mtime
- run: opam exec -- dune build '@install' -p trace,trace-tef,trace-fuchsia

View file

@ -47,22 +47,11 @@
(= :version)
:with-test))
dune)
(depopts
(mtime (>= 2.0)))
(tags
(trace ppx)))
(package
(name trace-subscriber)
(synopsis "Generic subscriber system for `trace`")
(depends
(ocaml
(>= 4.08))
(trace
(= :version))
(mtime
(>= 2.0)))
(tags
(trace subscriber)))
(package
(name trace-tef)
(synopsis

View file

@ -1,6 +1,13 @@
(library
(name trace_subscriber)
(public_name trace-subscriber)
(libraries (re_export trace.core) mtime mtime.clock.os threads))
(public_name trace.subscriber)
(libraries (re_export trace.core)
(select thread_.ml from
(threads -> thread_.real.ml)
( -> thread_.dummy.ml))
(select time_.ml from
(mtime mtime.clock.os -> time_.mtime.ml)
(mtime mtime.clock.jsoo -> time_.mtime.ml)
( -> time_.dummy.ml))))

View file

@ -0,0 +1 @@
let[@inline] get_tid () = 0

View file

@ -0,0 +1,2 @@
val get_tid : unit -> int
(** Get current thread ID *)

View file

@ -0,0 +1 @@
let[@inline] get_tid () = Thread.id @@ Thread.self ()

View file

@ -0,0 +1 @@
let[@inline] get_time_ns () : float = 0.

1
src/subscriber/time_.mli Normal file
View file

@ -0,0 +1 @@
val get_time_ns : unit -> float

View file

@ -0,0 +1,3 @@
let get_time_ns () : float =
let t = Mtime_clock.now () in
Int64.to_float (Mtime.to_uint64_ns t)

View file

@ -20,7 +20,7 @@ module Private_ = struct
let[@inline] tid_ () : int =
match !get_tid_ with
| Some f -> f ()
| None -> Thread.id (Thread.self ())
| None -> Thread_.get_tid ()
end
open struct

View file

@ -5,7 +5,7 @@
(libraries
trace.core
trace.private.util
trace-subscriber
trace.subscriber
trace-tef
unix
threads))

View file

@ -6,7 +6,7 @@
(libraries
trace.core
trace.private.util
trace-subscriber
trace.subscriber
mtime
mtime.clock.os
unix

View file

@ -1,34 +0,0 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
version: "0.7"
synopsis: "Generic subscriber system for `trace`"
maintainer: ["Simon Cruanes"]
authors: ["Simon Cruanes"]
license: "MIT"
tags: ["trace" "subscriber"]
homepage: "https://github.com/c-cube/ocaml-trace"
bug-reports: "https://github.com/c-cube/ocaml-trace/issues"
depends: [
"dune" {>= "2.9"}
"ocaml" {>= "4.08"}
"trace" {= version}
"mtime" {>= "2.0"}
"odoc" {with-doc}
]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"--promote-install-files=false"
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
["dune" "install" "-p" name "--create-install-files" name]
]
dev-repo: "git+https://github.com/c-cube/ocaml-trace.git"