package stk

  1. Overview
  2. Docs

Logging.

Stk uses a Logs.Src.t whose log functions are available in this module. Some modules also uses their own Logs.Src.t (like Textview or Textbuffer).

At load time, the environment variable STK_lOG_LEVEL is read to initialize the log level of log_src. Default is Logs.warning.

The create_src function creates a new log source whose messages are tagged with the "stk" tag. This is useful to separate Stk log messages from other log messages, as stk log messages should not be displayed in the Gui (this could cause some infinite loop). The creation of a new log source reads the corresponding environment variable to initialize the log level of the new source. For example, !create_src "stk.foo" will create a new log source and whose level will be initialized by looking at the STK_FOO_LOG_LEVEL.

Textlog module provides a Logs.reporter to dispatch messages based on the tags attached to the message.

val tag : unit Logs.Tag.def

Tag for Stk log messages.

module type LOG = sig ... end
val create_src : ?doc:'a -> string -> (module LOG)
include LOG
val log_src : Logs.Src.t
include Logs.LOG

Log functions

val msg : Logs.level -> 'a Logs.log
val app : 'a Logs.log

app is msg App.

val err : 'a Logs.log

err is msg Error.

val warn : 'a Logs.log

warn is msg Warning.

val info : 'a Logs.log

info is msg Info.

val debug : 'a Logs.log

debug is msg Debug.

val kmsg : (unit -> 'b) -> Logs.level -> ('a, 'b) Logs.msgf -> 'b

Logging result value Errors

val on_error : ?level:Logs.level -> ?header:string -> ?tags:Logs.Tag.set -> pp:(Format.formatter -> 'b -> unit) -> use:('b -> 'a) -> ('a, 'b) result -> 'a
val on_error_msg : ?level:Logs.level -> ?header:string -> ?tags:Logs.Tag.set -> use:(unit -> 'a) -> ('a, [ `Msg of string ]) result -> 'a
val src_list : unit -> Logs.src list

The list of stk log sources (i.e. the log sources created by create_src).

OCaml

Innovation. Community. Security.