Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package ocaml-logs for openSUSE:Factory checked in at 2021-06-14 23:11:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ocaml-logs (Old) and /work/SRC/openSUSE:Factory/.ocaml-logs.new.32437 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ocaml-logs" Mon Jun 14 23:11:18 2021 rev:2 rq:899952 version:0.7.0 Changes: -------- --- /work/SRC/openSUSE:Factory/ocaml-logs/ocaml-logs.changes 2021-04-29 01:37:27.542498381 +0200 +++ /work/SRC/openSUSE:Factory/.ocaml-logs.new.32437/ocaml-logs.changes 2021-06-14 23:11:46.800825752 +0200 @@ -1,0 +2,6 @@ +Mon Jun 7 13:13:13 UTC 2021 - oher...@suse.de + +- Update to version 0.7.0 + no actual code changes + +------------------------------------------------------------------- Old: ---- ocaml-logs-0.6.3.tar.xz New: ---- ocaml-logs-0.7.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ocaml-logs.spec ++++++ --- /var/tmp/diff_new_pack.iJwXeB/_old 2021-06-14 23:11:47.436826901 +0200 +++ /var/tmp/diff_new_pack.iJwXeB/_new 2021-06-14 23:11:47.436826901 +0200 @@ -17,7 +17,7 @@ Name: ocaml-logs -Version: 0.6.3 +Version: 0.7.0 Release: 0 %{?ocaml_preserve_bytecode} Summary: Logging infrastructure for OCaml ++++++ _service ++++++ --- /var/tmp/diff_new_pack.iJwXeB/_old 2021-06-14 23:11:47.460826944 +0200 +++ /var/tmp/diff_new_pack.iJwXeB/_new 2021-06-14 23:11:47.460826944 +0200 @@ -1,10 +1,10 @@ <services> <service name="tar_scm" mode="disabled"> <param name="filename">ocaml-logs</param> - <param name="revision">ab380230ff2c487167a232d9b76c5d8a922ed2d4</param> + <param name="revision">346f2cb5279a0dfee0e57fff109b8994982ce66f</param> <param name="scm">git</param> <param name="submodules">disable</param> - <param name="url">https://github.com/dune-universe/logs.git</param> + <param name="url">https://github.com/dbuenzli/logs.git</param> <param name="versionformat">@PARENT_TAG@</param> <param name="versionrewrite-pattern">[v]?([^\+]+)(.*)</param> <param name="versionrewrite-replacement">\1</param> ++++++ ocaml-logs-0.6.3.tar.xz -> ocaml-logs-0.7.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-logs-0.6.3/.gitignore new/ocaml-logs-0.7.0/.gitignore --- old/ocaml-logs-0.6.3/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/ocaml-logs-0.7.0/.gitignore 2019-08-09 18:33:48.000000000 +0200 @@ -0,0 +1,10 @@ +_b0 +_build +tmp +*~ +\.\#* +\#*# +*.native +*.byte +*.html +*.install \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-logs-0.6.3/CHANGES.md new/ocaml-logs-0.7.0/CHANGES.md --- old/ocaml-logs-0.6.3/CHANGES.md 2019-04-18 17:34:12.000000000 +0200 +++ new/ocaml-logs-0.7.0/CHANGES.md 2019-08-09 18:33:48.000000000 +0200 @@ -1,3 +1,14 @@ +v0.7.0 2019-08-09 Zagreb +------------------------ + +Support for thread safe logging, thanks to Jules Aguillon for the +work. + +* Add `Logs.set_reporter_mutex` for installing mutual exclusion + primitives to access the reporter. +* Add `Logs_threaded.enable` to install mutual exclusion + primitives for OCaml threads. + v0.6.3 2019-04-19 La Forclaz (VS) --------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-logs-0.6.3/README.md new/ocaml-logs-0.7.0/README.md --- old/ocaml-logs-0.6.3/README.md 2019-04-18 17:34:12.000000000 +0200 +++ new/ocaml-logs-0.7.0/README.md 2019-08-09 18:33:48.000000000 +0200 @@ -44,7 +44,7 @@ ## Sample programs -If you installed Logs with `opam` sample programs are located in the directory +If you installed Logs with `opam` sample programs are located in the directory `opam config var logs:doc`. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-logs-0.6.3/_tags new/ocaml-logs-0.7.0/_tags --- old/ocaml-logs-0.6.3/_tags 2019-04-18 17:34:12.000000000 +0200 +++ new/ocaml-logs-0.7.0/_tags 2019-08-09 18:33:48.000000000 +0200 @@ -1,10 +1,12 @@ true : bin_annot, safe_string +<_b0> : -traverse <src> : include <src/logs_fmt*> : package(fmt) <src/logs_browser*> : package(js_of_ocaml) <src/logs_cli*> : package(cmdliner) <src/logs_lwt*> : package(lwt) <src/logs_top*> : package(compiler-libs.toplevel) +<src/logs_threaded*> : thread, package(threads) <test> : include <test/tool*> : package(fmt), package(fmt.tty), package(fmt.cli), \ package(cmdliner) @@ -13,4 +15,5 @@ <test/test_lwt*> : package(lwt), package(lwt.unix), package(fmt), \ package(fmt.tty) <test/tags*> : package(mtime.clock.os) -<test/test_multi*> : package(fmt), package(fmt.tty) \ No newline at end of file +<test/test_multi*> : package(fmt), package(fmt.tty) +<test/test_threaded*> : thread, package(threads), package(fmt) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-logs-0.6.3/doc/dev-api.odocl new/ocaml-logs-0.7.0/doc/dev-api.odocl --- old/ocaml-logs-0.6.3/doc/dev-api.odocl 2019-04-18 17:34:12.000000000 +0200 +++ new/ocaml-logs-0.7.0/doc/dev-api.odocl 1970-01-01 01:00:00.000000000 +0100 @@ -1,5 +0,0 @@ -Logs -Logs_browser -Logs_cli -Logs_fmt -Logs_lwt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-logs-0.6.3/doc/index.mld new/ocaml-logs-0.7.0/doc/index.mld --- old/ocaml-logs-0.6.3/doc/index.mld 1970-01-01 01:00:00.000000000 +0100 +++ new/ocaml-logs-0.7.0/doc/index.mld 2019-08-09 18:33:48.000000000 +0200 @@ -0,0 +1,21 @@ +{0 Logs {%html: <span class="version">%%VERSION%%</span>%}} + +Logs provides a logging infrastructure. + +Logging is performed on sources whose reporting level can be set +independently. Log message report is decoupled from logging and is +handled by a reporter. A few optional log reporters are distributed +with the package and the API easily allows to implement your own. + +See the {{!Logs.basics}basics}. + +{1:api API} + +{!modules: +Logs +Logs_browser +Logs_cli +Logs_fmt +Logs_lwt +Logs_threaded +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-logs-0.6.3/opam new/ocaml-logs-0.7.0/opam --- old/ocaml-logs-0.6.3/opam 2019-04-18 17:34:12.000000000 +0200 +++ new/ocaml-logs-0.7.0/opam 2019-08-09 18:33:48.000000000 +0200 @@ -17,7 +17,9 @@ "js_of_ocaml" "fmt" "cmdliner" - "lwt" ] + "lwt" + "base-threads" +] conflicts: [ "js_of_ocaml" { < "3.3.0" } ] @@ -27,4 +29,6 @@ "--with-js_of_ocaml" "%{js_of_ocaml:installed}%" "--with-fmt" "%{fmt:installed}%" "--with-cmdliner" "%{cmdliner:installed}%" - "--with-lwt" "%{lwt:installed}%" ]] + "--with-lwt" "%{lwt:installed}%" + "--with-base-threads" "%{base-threads:installed}%" +]] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-logs-0.6.3/pkg/META new/ocaml-logs-0.7.0/pkg/META --- old/ocaml-logs-0.6.3/pkg/META 2019-04-18 17:34:12.000000000 +0200 +++ new/ocaml-logs-0.7.0/pkg/META 2019-08-09 18:33:48.000000000 +0200 @@ -1,5 +1,6 @@ description = "Logging infrastructure for OCaml" version = "%%VERSION_NUM%%" +requires = "" archive(byte) = "logs.cma" archive(native) = "logs.cmxa" plugin(byte) = "logs.cma" @@ -49,6 +50,17 @@ exists_if = "logs_lwt.cma" ) +package "threaded" ( + description = "Thread safe logging" + version = "%%VERSION_NUM%%" + requires = "logs threads" + archive(byte) = "logs_threaded.cma" + archive(native) = "logs_threaded.cmxa" + plugin(byte) = "logs_threaded.cma" + plugin(native) = "logs_threaded.cmxs" + exists_if = "logs_threaded.cma" +) + package "top" ( description = "Logs toplevel support" version = "%%VERSION_NUM%%" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-logs-0.6.3/pkg/pkg.ml new/ocaml-logs-0.7.0/pkg/pkg.ml --- old/ocaml-logs-0.6.3/pkg/pkg.ml 2019-04-18 17:34:12.000000000 +0200 +++ new/ocaml-logs-0.7.0/pkg/pkg.ml 2019-08-09 18:33:48.000000000 +0200 @@ -7,6 +7,7 @@ let cmdliner = Conf.with_pkg "cmdliner" let fmt = Conf.with_pkg "fmt" let lwt = Conf.with_pkg "lwt" +let threads = Conf.with_pkg "base-threads" let () = Pkg.describe "logs" @@ fun c -> @@ -14,12 +15,14 @@ let cmdliner = Conf.value c cmdliner in let fmt = Conf.value c fmt in let lwt = Conf.value c lwt in + let threads = Conf.value c threads in Ok [ Pkg.mllib "src/logs.mllib"; Pkg.mllib ~cond:fmt "src/logs_fmt.mllib"; Pkg.mllib ~cond:jsoo "src/logs_browser.mllib"; Pkg.mllib ~cond:cmdliner "src/logs_cli.mllib"; Pkg.mllib ~cond:lwt "src/logs_lwt.mllib"; Pkg.mllib ~cond:fmt ~api:[] "src/logs_top.mllib"; + Pkg.mllib ~cond:threads "src/logs_threaded.mllib"; Pkg.lib "src/logs_top_init.ml"; Pkg.lib "src/logs_fmt_top_init.ml"; Pkg.doc "test/tool.ml"; @@ -31,5 +34,6 @@ Pkg.test "test/test_multi"; (* Pkg.test "test/test_browser.js"; Pkg.test "test/test_browser.html"; *) + Pkg.test "test/test_threaded"; Pkg.test "test/test_lwt"; ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-logs-0.6.3/src/logs.ml new/ocaml-logs-0.7.0/src/logs.ml --- old/ocaml-logs-0.6.3/src/logs.ml 2019-04-18 17:34:12.000000000 +0200 +++ new/ocaml-logs-0.7.0/src/logs.ml 2019-08-09 18:33:48.000000000 +0200 @@ -178,6 +178,10 @@ (?header:string -> ?tags:Tag.set -> ('a, Format.formatter, unit, 'b) format4 -> 'a) -> 'b +type reporter_mutex = { lock : unit -> unit; unlock : unit -> unit } +let _reporter_mutex = ref { lock = (fun () -> ()); unlock = (fun () -> ()) } +let set_reporter_mutex ~lock ~unlock = _reporter_mutex := { lock; unlock } + type reporter = { report : 'a 'b. src -> level -> over:(unit -> unit) -> (unit -> 'b) -> @@ -187,7 +191,10 @@ let _reporter = ref nop_reporter let set_reporter r = _reporter := r let reporter () = !_reporter -let report src level ~over k msgf = !_reporter.report src level ~over k msgf +let report src level ~over k msgf = + let over () = over (); !_reporter_mutex.unlock () in + !_reporter_mutex.lock (); + !_reporter.report src level ~over k msgf let pp_header ppf (l, h) = match h with | None -> if l = App then () else Format.fprintf ppf "[%a]" pp_level l @@ -234,7 +241,8 @@ let over () = () let kmsg : type a b. (unit -> b) -> ?src:src -> level -> (a, b) msgf -> b = -fun k ?(src = default) level msgf -> match Src.level src with +fun k ?(src = default) level msgf -> +match Src.level src with | None -> k () | Some level' when level > level' -> (if level = Error then incr _err_count else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-logs-0.6.3/src/logs.mli new/ocaml-logs-0.7.0/src/logs.mli --- old/ocaml-logs-0.6.3/src/logs.mli 2019-04-18 17:34:12.000000000 +0200 +++ new/ocaml-logs-0.7.0/src/logs.mli 2019-08-09 18:33:48.000000000 +0200 @@ -346,6 +346,12 @@ val set_reporter : reporter -> unit (** [set_reporter r] sets the current reporter to [r]. *) +val set_reporter_mutex : lock:(unit -> unit) -> unlock:(unit -> unit) -> unit +(** [set_reporter_mutex ~lock ~unlock] sets the mutex primitives used + to access the reporter. [lock] is called before invoking the + reporter and [unlock] after it returns. Initially both [lock] and + [unlock] are [fun () -> ()]. *) + (**/**) val report : src -> level -> over:(unit -> unit) -> (unit -> 'b) -> ('a, 'b) msgf -> 'b @@ -427,6 +433,12 @@ install code before these initialization bits are being executed otherwise you will miss these messages. + In multi-threaded programs you likely want to ensure mutual + exclusion on reporter access. This can be done by invoking + {!Logs.set_reporter_mutex} with suitable mutual exclusion + primitives. If you use OCaml {!Thread}s simply calling + {!Logs_threaded.enable} with handle that for you. + If you need to use multiple reporters in your program see this {{!ex2}sample code}. @@ -437,7 +449,7 @@ If you are writing a library you should neither install reporters, nor set the reporting level of sources, nor log on the {!default} source or at the [App] level; follow the {{!usage}the usage conventions}. A - library should simply log on an another existing source or define + library should simply log on another existing source or define its own source like in the example below: {[ let src = Logs.Src.create "mylib.network" ~doc:"logs mylib's network events" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-logs-0.6.3/src/logs_threaded.ml new/ocaml-logs-0.7.0/src/logs_threaded.ml --- old/ocaml-logs-0.6.3/src/logs_threaded.ml 1970-01-01 01:00:00.000000000 +0100 +++ new/ocaml-logs-0.7.0/src/logs_threaded.ml 2019-08-09 18:33:48.000000000 +0200 @@ -0,0 +1,26 @@ +(*--------------------------------------------------------------------------- + Copyright (c) 2019 The logs programmers. All rights reserved. + Distributed under the ISC license, see terms at the end of the file. + %%NAME%% %%VERSION%% + ---------------------------------------------------------------------------*) + +let enable () = + let lock = Mutex.create () in + let lock () = Mutex.lock lock and unlock () = Mutex.unlock lock in + Logs.set_reporter_mutex ~lock ~unlock + +(*--------------------------------------------------------------------------- + Copyright (c) 2019 The logs programmers + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + ---------------------------------------------------------------------------*) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-logs-0.6.3/src/logs_threaded.mli new/ocaml-logs-0.7.0/src/logs_threaded.mli --- old/ocaml-logs-0.6.3/src/logs_threaded.mli 1970-01-01 01:00:00.000000000 +0100 +++ new/ocaml-logs-0.7.0/src/logs_threaded.mli 2019-08-09 18:33:48.000000000 +0200 @@ -0,0 +1,28 @@ +(*--------------------------------------------------------------------------- + Copyright (c) 2019 The logs programmers. All rights reserved. + Distributed under the ISC license, see terms at the end of the file. + %%NAME%% %%VERSION%% + ---------------------------------------------------------------------------*) + +(** Thread safe logging. *) + +val enable : unit -> unit +(** [enable ()] enables thread safe logging for OCaml {!Thread}s by + installing mutual exclusion primitives via + {!Logs.set_reporter_mutex}. *) + +(*--------------------------------------------------------------------------- + Copyright (c) 2019 The logs programmers + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + ---------------------------------------------------------------------------*) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-logs-0.6.3/src/logs_threaded.mllib new/ocaml-logs-0.7.0/src/logs_threaded.mllib --- old/ocaml-logs-0.6.3/src/logs_threaded.mllib 1970-01-01 01:00:00.000000000 +0100 +++ new/ocaml-logs-0.7.0/src/logs_threaded.mllib 2019-08-09 18:33:48.000000000 +0200 @@ -0,0 +1 @@ +Logs_threaded diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-logs-0.6.3/test/test_threaded.ml new/ocaml-logs-0.7.0/test/test_threaded.ml --- old/ocaml-logs-0.6.3/test/test_threaded.ml 1970-01-01 01:00:00.000000000 +0100 +++ new/ocaml-logs-0.7.0/test/test_threaded.ml 2019-08-09 18:33:48.000000000 +0200 @@ -0,0 +1,14 @@ +let loop s = + for _ = 0 to 10 do + Logs.info (fun f -> f "%s.%s" s s) + done + +let () = + Logs_threaded.enable (); + Logs.set_level (Some Logs.Debug); + Logs.set_reporter (Logs_fmt.reporter ()); + let t1 = Thread.create loop "aaaa" in + let t2 = Thread.create loop "bbbb" in + loop "cccc"; + Thread.join t1; + Thread.join t2 ++++++ ocaml-logs.patch ++++++ --- /var/tmp/diff_new_pack.iJwXeB/_old 2021-06-14 23:11:47.508827030 +0200 +++ /var/tmp/diff_new_pack.iJwXeB/_new 2021-06-14 23:11:47.508827030 +0200 @@ -53,135 +53,3 @@ + (libraries compiler-libs.toplevel logs) + (modules logs_top) + (wrapped false)) ---- a/src/logs.ml -+++ b/src/logs.ml -@@ -178,6 +178,10 @@ type ('a, 'b) msgf = - (?header:string -> ?tags:Tag.set -> - ('a, Format.formatter, unit, 'b) format4 -> 'a) -> 'b - -+type reporter_mutex = { lock : unit -> unit; unlock : unit -> unit } -+let _reporter_mutex = ref { lock = (fun () -> ()); unlock = (fun () -> ()) } -+let set_reporter_mutex ~lock ~unlock = _reporter_mutex := { lock; unlock } -+ - type reporter = - { report : - 'a 'b. src -> level -> over:(unit -> unit) -> (unit -> 'b) -> -@@ -187,7 +191,10 @@ let nop_reporter = { report = fun _ _ ~over k _ -> over (); k () } - let _reporter = ref nop_reporter - let set_reporter r = _reporter := r - let reporter () = !_reporter --let report src level ~over k msgf = !_reporter.report src level ~over k msgf -+let report src level ~over k msgf = -+ let over () = over (); !_reporter_mutex.unlock () in -+ !_reporter_mutex.lock (); -+ !_reporter.report src level ~over k msgf - - let pp_header ppf (l, h) = match h with - | None -> if l = App then () else Format.fprintf ppf "[%a]" pp_level l -@@ -234,7 +241,8 @@ type 'a log = ('a, unit) msgf -> unit - - let over () = () - let kmsg : type a b. (unit -> b) -> ?src:src -> level -> (a, b) msgf -> b = --fun k ?(src = default) level msgf -> match Src.level src with -+fun k ?(src = default) level msgf -> -+match Src.level src with - | None -> k () - | Some level' when level > level' -> - (if level = Error then incr _err_count else ---- a/src/logs.mli -+++ b/src/logs.mli -@@ -346,6 +346,12 @@ val reporter : unit -> reporter - val set_reporter : reporter -> unit - (** [set_reporter r] sets the current reporter to [r]. *) - -+val set_reporter_mutex : lock:(unit -> unit) -> unlock:(unit -> unit) -> unit -+(** [set_reporter_mutex ~lock ~unlock] sets the mutex primitives used -+ to access the reporter. [lock] is called before invoking the -+ reporter and [unlock] after it returns. Initially both [lock] and -+ [unlock] are [fun () -> ()]. *) -+ - (**/**) - val report : src -> level -> over:(unit -> unit) -> (unit -> 'b) -> - ('a, 'b) msgf -> 'b -@@ -427,6 +433,12 @@ let main () = - install code before these initialization bits are being executed - otherwise you will miss these messages. - -+ In multi-threaded programs you likely want to ensure mutual -+ exclusion on reporter access. This can be done by invoking -+ {!Logs.set_reporter_mutex} with suitable mutual exclusion -+ primitives. If you use OCaml {!Thread}s simply calling -+ {!Logs_threaded.enable} with handle that for you. -+ - If you need to use multiple reporters in your program see this - {{!ex2}sample code}. - -@@ -437,7 +449,7 @@ let main () = - If you are writing a library you should neither install reporters, nor - set the reporting level of sources, nor log on the {!default} source or - at the [App] level; follow the {{!usage}the usage conventions}. A -- library should simply log on an another existing source or define -+ library should simply log on another existing source or define - its own source like in the example below: - {[ - let src = Logs.Src.create "mylib.network" ~doc:"logs mylib's network events" ---- /dev/null -+++ b/src/logs_threaded.ml -@@ -0,0 +1,26 @@ -+(*--------------------------------------------------------------------------- -+ Copyright (c) 2019 The logs programmers. All rights reserved. -+ Distributed under the ISC license, see terms at the end of the file. -+ %%NAME%% %%VERSION%% -+ ---------------------------------------------------------------------------*) -+ -+let enable () = -+ let lock = Mutex.create () in -+ let lock () = Mutex.lock lock and unlock () = Mutex.unlock lock in -+ Logs.set_reporter_mutex ~lock ~unlock -+ -+(*--------------------------------------------------------------------------- -+ Copyright (c) 2019 The logs programmers -+ -+ Permission to use, copy, modify, and/or distribute this software for any -+ purpose with or without fee is hereby granted, provided that the above -+ copyright notice and this permission notice appear in all copies. -+ -+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -+ ---------------------------------------------------------------------------*) ---- /dev/null -+++ b/src/logs_threaded.mli -@@ -0,0 +1,28 @@ -+(*--------------------------------------------------------------------------- -+ Copyright (c) 2019 The logs programmers. All rights reserved. -+ Distributed under the ISC license, see terms at the end of the file. -+ %%NAME%% %%VERSION%% -+ ---------------------------------------------------------------------------*) -+ -+(** Thread safe logging. *) -+ -+val enable : unit -> unit -+(** [enable ()] enables thread safe logging for OCaml {!Thread}s by -+ installing mutual exclusion primitives via -+ {!Logs.set_reporter_mutex}. *) -+ -+(*--------------------------------------------------------------------------- -+ Copyright (c) 2019 The logs programmers -+ -+ Permission to use, copy, modify, and/or distribute this software for any -+ purpose with or without fee is hereby granted, provided that the above -+ copyright notice and this permission notice appear in all copies. -+ -+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -+ ---------------------------------------------------------------------------*)