mirror of
https://github.com/ocaml-tracing/ocaml-trace.git
synced 2026-03-09 04:17:56 -04: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
|
- run: opam pin odoc 2.2.2 -y -n
|
||||||
# crash with 2.4, see https://github.com/ocaml/odoc/issues/1066
|
# crash with 2.4, see https://github.com/ocaml/odoc/issues/1066
|
||||||
- name: Deps
|
- 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
|
- 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
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
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
|
dune-cache: true
|
||||||
allow-prerelease-opam: 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
|
- run: opam install ppx_trace --deps-only # no tests
|
||||||
if: matrix.ocaml-compiler != '4.08.x'
|
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
|
- run: opam exec -- dune build '@install' -p ppx_trace
|
||||||
if: matrix.ocaml-compiler != '4.08.x'
|
if: matrix.ocaml-compiler != '4.08.x'
|
||||||
- run: opam exec -- dune runtest -p trace
|
- run: opam exec -- dune runtest -p trace
|
||||||
- run: opam install 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
|
# with depopts
|
||||||
- run: opam install hmap
|
- run: opam install hmap mtime
|
||||||
- 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
|
||||||
|
|
||||||
|
|
|
||||||
15
dune-project
15
dune-project
|
|
@ -47,22 +47,11 @@
|
||||||
(= :version)
|
(= :version)
|
||||||
:with-test))
|
:with-test))
|
||||||
dune)
|
dune)
|
||||||
|
(depopts
|
||||||
|
(mtime (>= 2.0)))
|
||||||
(tags
|
(tags
|
||||||
(trace ppx)))
|
(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
|
(package
|
||||||
(name trace-tef)
|
(name trace-tef)
|
||||||
(synopsis
|
(synopsis
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,13 @@
|
||||||
|
|
||||||
(library
|
(library
|
||||||
(name trace_subscriber)
|
(name trace_subscriber)
|
||||||
(public_name trace-subscriber)
|
(public_name trace.subscriber)
|
||||||
(libraries (re_export trace.core) mtime mtime.clock.os threads))
|
(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 =
|
let[@inline] tid_ () : int =
|
||||||
match !get_tid_ with
|
match !get_tid_ with
|
||||||
| Some f -> f ()
|
| Some f -> f ()
|
||||||
| None -> Thread.id (Thread.self ())
|
| None -> Thread_.get_tid ()
|
||||||
end
|
end
|
||||||
|
|
||||||
open struct
|
open struct
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
(libraries
|
(libraries
|
||||||
trace.core
|
trace.core
|
||||||
trace.private.util
|
trace.private.util
|
||||||
trace-subscriber
|
trace.subscriber
|
||||||
trace-tef
|
trace-tef
|
||||||
unix
|
unix
|
||||||
threads))
|
threads))
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
(libraries
|
(libraries
|
||||||
trace.core
|
trace.core
|
||||||
trace.private.util
|
trace.private.util
|
||||||
trace-subscriber
|
trace.subscriber
|
||||||
mtime
|
mtime
|
||||||
mtime.clock.os
|
mtime.clock.os
|
||||||
unix
|
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