Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dra27 committed Aug 11, 2018
1 parent 2ba96b7 commit b4fded5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/logs_syslog_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,21 @@ let unix_reporter
| None -> (fun msg -> msg), Unix.SOCK_DGRAM
in
let sa = Unix.ADDR_UNIX socket in
let encode = Syslog_message.encode_local in
let encode ?(len=1024) (msg : Syslog_message.t) =
let open Syslog_message in
let open Astring in
let f v g =
if v = g then failwith "Invalid value" else (Obj.magic v : int)
in
let facse =
f msg.facility Invalid_Facility * 8 + f msg.severity Invalid_Severity
and ts = Rfc3164_Timestamp.encode msg.timestamp
in
let msgstr = Printf.sprintf "<%d>%s %s" facse ts msg.message
in
if len > 0 && String.length msgstr > len then
String.with_range ~first:0 ~len:len msgstr
else
msgstr
in
conn_reporter Unix.PF_UNIX socket_type sa truncate frame encode "localhost"

0 comments on commit b4fded5

Please sign in to comment.