mirror of
https://github.com/ocaml-tracing/ocaml-trace.git
synced 2026-03-07 18:37:56 -05:00
refactor: use trace.subscriber instead of a separate library
This commit is contained in:
parent
cc6c311b45
commit
6920c3341a
14 changed files with 30 additions and 59 deletions
4
.github/workflows/gh-pages.yml
vendored
4
.github/workflows/gh-pages.yml
vendored
|
|
@ -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
|
||||
|
|
|
|||
10
.github/workflows/main.yml
vendored
10
.github/workflows/main.yml
vendored
|
|
@ -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
|
||||
|
||||
|
|
|
|||
15
dune-project
15
dune-project
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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))))
|
||||
|
||||
|
|
|
|||
1
src/subscriber/thread_.dummy.ml
Normal file
1
src/subscriber/thread_.dummy.ml
Normal file
|
|
@ -0,0 +1 @@
|
|||
let[@inline] get_tid () = 0
|
||||
2
src/subscriber/thread_.mli
Normal file
2
src/subscriber/thread_.mli
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
val get_tid : unit -> int
|
||||
(** Get current thread ID *)
|
||||
1
src/subscriber/thread_.real.ml
Normal file
1
src/subscriber/thread_.real.ml
Normal file
|
|
@ -0,0 +1 @@
|
|||
let[@inline] get_tid () = Thread.id @@ Thread.self ()
|
||||
1
src/subscriber/time_.dummy.ml
Normal file
1
src/subscriber/time_.dummy.ml
Normal file
|
|
@ -0,0 +1 @@
|
|||
let[@inline] get_time_ns () : float = 0.
|
||||
1
src/subscriber/time_.mli
Normal file
1
src/subscriber/time_.mli
Normal file
|
|
@ -0,0 +1 @@
|
|||
val get_time_ns : unit -> float
|
||||
3
src/subscriber/time_.mtime.ml
Normal file
3
src/subscriber/time_.mtime.ml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
let get_time_ns () : float =
|
||||
let t = Mtime_clock.now () in
|
||||
Int64.to_float (Mtime.to_uint64_ns t)
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
(libraries
|
||||
trace.core
|
||||
trace.private.util
|
||||
trace-subscriber
|
||||
trace.subscriber
|
||||
trace-tef
|
||||
unix
|
||||
threads))
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
(libraries
|
||||
trace.core
|
||||
trace.private.util
|
||||
trace-subscriber
|
||||
trace.subscriber
|
||||
mtime
|
||||
mtime.clock.os
|
||||
unix
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
Loading…
Add table
Reference in a new issue