package async_log

  1. Overview
  2. Docs
type t

A t represents a log message with additional structured information about the statement, for use by outputs. Most outputs flatten the event to a Message.t, which predates this module and is serializable / deserializable, but has less structured information.

(This module's signature is tight / bare to keep the type extensible and backwards-compatible with previous behaviour, but this isn't intended to deter any users who may wish for an accessor to be added, especially for newer structured info in Message_sexp.t.)

val create : ?time:Core.Time_float.t -> ?source:string -> ?legacy_tags:(string * string) list -> ?level:Level.t -> Ppx_log_types.Message_data.t -> t
val raw_message : t -> Ppx_log_types.Message_data.t
val message : t -> string
val legacy_tags : t -> (string * string) list
val level : t -> Level.t option
val time : t -> Core.Time_float.t
val add_tags : t -> tags:(string * string) list -> t
val map_legacy_tags : t -> f:((string * string) -> string * string) -> t
val stringify_message_and_map : t -> f:(string -> string) -> t

Convert any structured messages to a string and map. The structured format is not recovered afterwards. This is mainly used for convenience in testing outputs.

val downgrade_to_unstructured_and_map : t -> f: ([ `Sexp of Core.Sexp.t | `String of string ] -> [ `Sexp of Core.Sexp.t | `String of string ]) -> t

Convert any structured messages to the unstructured sexp format and map. The structured format is not recovered afterwards.

This is used by old code that predates the structured messages, often to censor certain fields out of log messages.

val set_level : t -> level:Level.t option -> t
val to_serialized_message_lossy : t -> Message.t
val of_serialized_message : Message.t -> t
module Unstable : sig ... end
module Private : sig ... end
OCaml

Innovation. Community. Security.