fix JOURNAL_STREAM detection to make sure its actually a sd service
This commit is contained in:
parent
d936d36a6a
commit
096cd62b2b
|
@ -14,12 +14,11 @@ let no_timestamp = Option.is_some (Sys.getenv_opt "LOG_NO_TIMESTAMP")
|
||||||
let no_namespace = Option.is_some (Sys.getenv_opt "LOG_NO_NAMESPACE")
|
let no_namespace = Option.is_some (Sys.getenv_opt "LOG_NO_NAMESPACE")
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
match Sys.getenv_opt "JOURNAL_STREAM" with
|
if Logging.should_upgrade_to_journald () then
|
||||||
| Some _ ->
|
|
||||||
Logging.init_journald_writer ()
|
Logging.init_journald_writer ()
|
||||||
~min_level
|
~min_level
|
||||||
| None ->
|
else
|
||||||
Logging.init_pretty_writer stderr
|
Logging.init_pretty_writer stdout
|
||||||
~min_level
|
~min_level
|
||||||
~color:(not no_color)
|
~color:(not no_color)
|
||||||
~timestamp:(not no_timestamp)
|
~timestamp:(not no_timestamp)
|
||||||
|
|
|
@ -9,6 +9,11 @@ type t = {
|
||||||
buf : Buffer.t;
|
buf : Buffer.t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let should_upgrade () =
|
||||||
|
let stderr = Unix.fstat Unix.stderr in
|
||||||
|
let dev_ino = Printf.sprintf "%d:%d" stderr.st_dev stderr.st_ino in
|
||||||
|
Sys.getenv_opt "JOURNAL_STREAM" = Some dev_ino
|
||||||
|
|
||||||
let make ?(path = default_socket_path) () = {
|
let make ?(path = default_socket_path) () = {
|
||||||
mutex = Mutex.create ();
|
mutex = Mutex.create ();
|
||||||
sock_fd = Unix.socket PF_UNIX SOCK_DGRAM 0 ~cloexec:true;
|
sock_fd = Unix.socket PF_UNIX SOCK_DGRAM 0 ~cloexec:true;
|
||||||
|
|
|
@ -107,3 +107,5 @@ let init_journald_writer
|
||||||
Journald.make () ?path |>
|
Journald.make () ?path |>
|
||||||
Journald.writer |>
|
Journald.writer |>
|
||||||
add_writer ?min_level
|
add_writer ?min_level
|
||||||
|
|
||||||
|
let should_upgrade_to_journald = Journald.should_upgrade
|
||||||
|
|
|
@ -36,3 +36,5 @@ val init_journald_writer :
|
||||||
?min_level:level ->
|
?min_level:level ->
|
||||||
?path:string ->
|
?path:string ->
|
||||||
unit -> unit
|
unit -> unit
|
||||||
|
|
||||||
|
val should_upgrade_to_journald : unit -> bool
|
||||||
|
|
Loading…
Reference in New Issue