diff --git a/lib/logging/journald.ml b/lib/logging/journald.ml index 87980bd..ba08f8e 100644 --- a/lib/logging/journald.ml +++ b/lib/logging/journald.ml @@ -36,12 +36,13 @@ let syslog_priority = function | ERROR -> "3" (* LOG_ERR *) let writer t ~ts ~ns ~lvl msg = + Mutex.lock t.mutex; let dgram = - Mutex.protect t.mutex @@ fun () -> Buffer.clear t.buf; ignore ts; add_field t.buf "MESSAGE" (Printf.sprintf "%s: %s" ns msg); add_field t.buf "PRIORITY" (syslog_priority lvl); Buffer.to_bytes t.buf in + Mutex.unlock t.mutex; Unix.sendto t.sock_fd dgram 0 (Bytes.length dgram) [] t.dest |> ignore diff --git a/lib/logging/mutex.ml b/lib/logging/mutex.ml new file mode 100644 index 0000000..7f95264 --- /dev/null +++ b/lib/logging/mutex.ml @@ -0,0 +1,5 @@ +(* stub implementation since we actually aren't multithreaded *) +type t = unit +external create : unit -> t = "%identity" +external lock : t -> unit = "%identity" +external unlock : t -> unit = "%identity"