Structured_log_events
The type of structured log events.
New structured log events may be registered using the @@deriving register_event
ppx. A new structured log event is a constructor of this type with either an inline record argument or no arguments. For example: {
t += Ctor1 of {a:int; b:string; c:M.t}
[@@deriving register_event
{msg= "Optional log message, possibly including $a, $b, and $c"}]
t += Ctor2 [@@deriving register_event]
}
val id_to_yojson : id -> Yojson.Safe.t
val id_of_yojson : Yojson.Safe.t -> id Ppx_deriving_yojson_runtime.error_or
val sexp_of_id : id -> Ppx_sexp_conv_lib.Sexp.t
val id_of_sexp : Ppx_sexp_conv_lib.Sexp.t -> id
val id_of_string : string -> id
Create an identifier for a structured log event. This is for internal use by the @@deriving register_event
ppx.
val string_of_id : id -> string
Retrieve the string representation of a structured log event. id_of_string (string_of_id id) = id
type repr = {
id : id; |
event_name : string; |
arguments : Core_kernel.String.Set.t; |
log : t -> (string * (string * Yojson.Safe.t) list) option; |
parse : (string * Yojson.Safe.t) list -> t option; |
}
The representation of a structured log event, used to convert the events to and from log messages. This is automatically generated by the @@deriving register_event
ppx.
val register_constructor : repr -> unit
Register a structured log event's representation. This is for internal use by the @@deriving register_event
ppx.
Convert a structured log message into JSON content for logging. log (Event_name {field_name1= field_value1; ...})
returns (log_message, log_event_id, [(field_name1, field_value1); ...])
, where the log message and ID are defined by @@deriving register_event
.
Parse a log message as a structured log event.
val dump_registered_events : unit -> (string * id * string list) list
Returns a list of the registered events, in the form (event_name, event_id, event_field_names)
.