Skip to content

Commit

Permalink
log: add process name, avoid splitting lines
Browse files Browse the repository at this point in the history
The @[ ... @] would do fancy line splitting and alignment, which we
really don't want. We want to stick to one line per log record for
easy parsing.

Signed-off-by: David Scott <dave@recoil.org>
  • Loading branch information
djs55 committed Apr 4, 2022
1 parent fe6705d commit ce4c786
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/bin/logging.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
Fmt.pf f "time=\"%04d-%02d-%02dT%02d:%02d:%02d.%09dZ\"" (tm.tm_year + 1900) (tm.tm_mon + 1)
tm.tm_mday tm.tm_hour tm.tm_min tm.tm_sec nsecs

let process = Filename.basename Sys.argv.(0)

let reporter =
let report src level ~over k msgf =
let k _ =
Expand All @@ -19,8 +21,9 @@ let reporter =
let level = Logs.level_to_string (Some level) in

Fmt.kpf k Fmt.stderr
("\r%a level=%a @[msg=\"%a: " ^^ fmt ^^ "\"@]@.")
("%a process=%a level=%a msg=\"%a: " ^^ fmt ^^ "\"@.")
pp_ptime ()
Fmt.string process
Fmt.string level
Fmt.string src

Expand Down

0 comments on commit ce4c786

Please sign in to comment.