Module Log.Output
module Format : sig ... end
val create : ?rotate:(unit -> unit Async_unix__.Import.Deferred.t) -> ?close:(unit -> unit Async_unix__.Import.Deferred.t) -> flush:(unit -> unit Async_unix__.Import.Deferred.t) -> (Message.t Core.Queue.t -> unit Async_unix__.Import.Deferred.t) -> t
create f
returns at
, 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 eachOutput.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 byLog
, but isn't automatically called at any other time. It can be called manually by callingLog.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 whenLog.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 writer : Format.t -> Async_unix.Writer.t -> t
val file : ?perm:Core.Unix.file_perm -> Format.t -> filename:string -> t
The
perm
argument is passed through toWriter.open_file
, and so has the default behavior described there.
val rotating_file : ?perm:Core.Unix.file_perm -> ?time_source:Async_unix__.Import.Synchronous_time_source.t -> Format.t -> basename:string -> Rotation.t -> t
val rotating_file_with_tail : ?perm:Core.Unix.file_perm -> ?time_source:Async_unix__.Import.Synchronous_time_source.t -> Format.t -> basename:string -> Rotation.t -> t * string Async_unix__.Import.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 thanlevel
.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 withset_level
, which is equivalent and more efficient.