package async_log

  1. Overview
  2. Docs
include module type of Async_log_kernel.Output
val create : ?rotate:(unit -> unit Async_kernel.Deferred.t) -> ?finalize:(unit -> unit Async_kernel.Deferred.t) -> flush:(unit -> unit Async_kernel.Deferred.t) -> (Async_log_kernel.Message.t Core.Queue.t -> unit Async_kernel.Deferred.t) -> t

create f returns a t, given a function that actually performs the final output work. It is the responsibility of the write function to contain all state, and to clean up after itself when it is garbage collected (which may require a finalizer). The function should avoid modifying the contents of the queue; it's reused for each Output.t.

flush should return a deferred that is fulfilled only when all previously written messages are durable (e.g., on disk, out on the network, etc.). It is automatically called by Log on shutdown and at garbage collection. It can be called manually by calling Log.flushed t.

The unit Deferred returned by the function provides an opportunity for pushback if that is important. Only one batch of messages will be "in flight" at any time based on this deferred.

finalize will be called when the output is finalized (meaning, no more open logs use the output, and references to the output are gone).

val create_expert : ?finalize:(unit -> unit Async_kernel.Deferred.t) -> flush:(unit -> unit Async_kernel.Deferred.t) -> (Async_log_kernel.Message_event.t Core.Queue.t -> unit Async_kernel.Deferred.t) -> t
val create_unbuffered : ?finalize:(unit -> unit Async_kernel.Deferred.t) -> flush:(unit -> unit Async_kernel.Deferred.t) -> (Async_log_kernel.Message_event.t -> unit) -> t

A version of create that writes without buffering internally and processing in a background loop as outputs usually do, and has access to richer information in the write callback.

val filter_to_level : t -> level:Async_log_kernel.Level.t -> t

filter_to_level wraps an output and gives you a new output which only logs messages which are as/more verbose than level.

This functionality is intended for when you have multiple outputs being displayed in different places, and they need to be at different levels.

If you have one output (or multiple outputs all at the same level), it is better to set the Log.t's output directly with set_level, which is equivalent and more efficient.

val empty : t
val rotate : t -> unit Async_kernel.Deferred.t
  • deprecated Do not introduce new uses of this function.
module Format : sig ... end
module Private : sig ... end
module For_testing : sig ... end
val stdout : ?format:Format.t -> unit -> t

stdout defaults to format=`Text

val stderr : ?format:Format.t -> unit -> t

stderr defaults to format=`Text

val writer : Format.t -> Async_unix.Writer.t -> t

The writer output type takes no responsibility over the Writer.t it is given. In particular it makes no attempt to ever close it.

val file : ?perm:Async_unix.Unix.file_perm -> Format.t -> filename:string -> t

The perm argument is passed through to Writer.open_file, and so has the default behavior described there.

val rotating_file : ?perm:Async_unix.Unix.file_perm -> ?time_source:Async_kernel.Synchronous_time_source.t -> ?log_on_rotation:(unit -> Message.t list) -> Format.t -> basename:string -> ?suffix:string -> Rotation.t -> t
val rotating_file_with_tail : ?perm:Async_unix.Unix.file_perm -> ?time_source:Async_kernel.Synchronous_time_source.t -> ?log_on_rotation:(unit -> Message.t list) -> Format.t -> basename:string -> ?suffix:string -> Rotation.t -> t * string Async_kernel.Tail.t

Returns a tail of the filenames. When rotate is called, the previous filename is put on the tail

See Log_extended for syslog and colorized console output.

OCaml

Innovation. Community. Security.