package async_unix

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
module Format : sig ... end
type t
val create : ?rotate:(unit -> unit Async_kernel.Deferred.t) -> ?close:(unit -> unit Async_kernel.Deferred.t) -> flush:(unit -> unit Async_kernel.Deferred.t) -> (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.

The "stock" output modules support a sexp and bin_prot output format, and other output modules should make efforts to support them as well where it is meaningful/appropriate to do so.

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 on shutdown by Log, but isn't automatically called at any other time. 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.

An optional rotate function may be given which will be called when Log.rotate t is called while this output is in effect. This is useful for programs that want very precise control over rotation.

If close is provided it will be called when the log falls out of scope. (Note that it is not called directly, even if you close a log which is using this output, because outputs are sometimes reused.)

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 -> Writer.t -> t
val file : ?perm:Core.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:Core.Unix.file_perm -> ?time_source:Async_kernel.Synchronous_time_source.t -> Format.t -> basename:string -> Rotation.t -> t
val rotating_file_with_tail : ?perm:Core.Unix.file_perm -> ?time_source:Async_kernel.Synchronous_time_source.t -> Format.t -> basename: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

val filter_to_level : t -> level: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.

See Log_extended for syslog and colorized console output.

OCaml

Innovation. Community. Security.