Module Spoc_core.Log

type level =
  1. | Debug
  2. | Info
  3. | Warn
  4. | Error

Log levels

type component =
  1. | Transfer
  2. | Kernel
  3. | Device
  4. | Memory
  5. | Execute
  6. | All

Components that can be logged

val level_to_int : level -> int

Level to int for comparison

val threshold : int Stdlib.Atomic.t
val bit : component -> int
val all_bits : int
val mask : int Stdlib.Atomic.t
val update_mask : (int -> int) -> unit
val enable : component -> unit

Enable a component

val disable : component -> unit

Disable a component

val set_level : level -> unit

Set log level

val component_of_string : string -> component option
val level_of_string : string -> level option
val init_from_env : unit -> unit

Enable from environment variable SAREK_DEBUG=transfer,kernel,... Use "*" or "all" to enable all components. A level (debug, info, warn, error) sets the level; naming a component without a level sets it to debug, so SAREK_DEBUG=kernel prints the kernel component's debug messages. Unknown words are ignored.

val is_enabled : component -> bool

Check if component is enabled

val would_log : level -> component -> bool

would_log level comp: a message at level on comp would be printed. Guard a call whose arguments cost something to compute with it.

val level_to_string : level -> string

Level to string

val component_to_string : component -> string

Component to string

val logf : level -> component -> ('a, Stdlib.out_channel, unit, unit) Stdlib.format4 -> 'a

Core logging function - printf style

val log : level -> component -> string -> unit

String-based logging (simpler, no format issues)

val log_any_component : level -> string -> unit

log_any_component level msg: msg tagged All, gated by the level only. For callers with their own switch (Spoc_core.Error.log), so they need not enable every component.

val debug : component -> string -> unit

Convenience functions - string based

val info : component -> string -> unit
val warn : component -> string -> unit
val error : component -> string -> unit
val debugf : component -> ('a, Stdlib.out_channel, unit, unit) Stdlib.format4 -> 'a

Convenience functions - printf style

val infof : component -> ('a, Stdlib.out_channel, unit, unit) Stdlib.format4 -> 'a
val warnf : component -> ('a, Stdlib.out_channel, unit, unit) Stdlib.format4 -> 'a
val errorf : component -> ('a, Stdlib.out_channel, unit, unit) Stdlib.format4 -> 'a