package devkit

  1. Overview
  2. Docs
Development kit - general purpose library

Install

Dune Dependency

Authors

Maintainers

Sources

devkit-1.20240429.tbz
sha256=222f8ac131b1d970dab7eeb2714bfd6b9338b88b1082e6e01c136ae19e7eaef4
sha512=c9e6d93e3d21e5530c0f4d5baca51bf1f0a5d19248f8af7678d0665bb5cdf295d7aaaaa3e50eb2e44b8720e55097cc675af4dc8ec45acf9da39feb3eae1405d5

doc/devkit.core/Devkit_core/Log/index.html

Module Devkit_core.LogSource

Global ready-to-use logger

TODO interface to manage State

Example usage

Create logging facility (messages origin)

let http = Log.facility "http"

Log from http subsystem at debug level

Log.debug http "received %u bytes"

Create and use object for http logging

let log = Log.from "http" (* new Log.logger http *);;
log#info "sent %u bytes" 1024
log#warn ~exn "failed here"

Output only messages of warning level or higher for the http facility

http#allow `Warn

or

Logger.set_filter http `Warn

or

Log.set_filter ~name:"http" `Warn

or

Log.set_filter ~name:"http*" `Warn

to set for all facilities starting with "http"

Output only messages of warning level or higher for all facilities

Log.set_filter `Warn

API

Sourcemodule State : sig ... end

Global logger state

include module type of struct include State.M end
Sourceval debug_s : Devkit_core__Logger.facil -> string -> unit
Sourceval info_s : Devkit_core__Logger.facil -> string -> unit
Sourceval warn_s : Devkit_core__Logger.facil -> string -> unit
Sourceval error_s : Devkit_core__Logger.facil -> string -> unit
Sourceval put_s : [ `Debug | `Info | `Warn | `Error ] -> Devkit_core__Logger.facil -> string -> unit
Sourceval debug : Devkit_core__Logger.facil -> ('a, unit, string, unit) format4 -> 'a
Sourceval info : Devkit_core__Logger.facil -> ('a, unit, string, unit) format4 -> 'a
Sourceval warn : Devkit_core__Logger.facil -> ('a, unit, string, unit) format4 -> 'a
Sourceval error : Devkit_core__Logger.facil -> ('a, unit, string, unit) format4 -> 'a
Sourceval facility : string -> Logger.facil
Sourceval set_filter : ?name:string -> Logger.level -> unit
Sourceval set_loglevels : string -> unit
Sourceval set_utc : unit -> unit
Sourceval read_env_config : ?env:string -> unit -> unit

Update facilities configuration from the environment.

By default, it reads the configuration in the environment variable DEVKIT_LOG which can be overwritten using the optional process_name parameter.

The value of environment variable should match the following grammar: ([<facil|prefix*>=]debug|info|warn|error[,])*

  • raises Failure

    on invalid level values of wrong format

Sourcetype 'a pr = ?exn:exn -> ?lines:bool -> ?backtrace:bool -> ?saved_backtrace:string list -> ('a, unit, string, unit) format4 -> 'a

param lines: whether to split multiline message as separate log lines (default true)

param backtrace: whether to show backtrace (default is true if exn is given and backtrace recording is enabled)

param saved_backtrace: supply backtrace to show instead of using Printexc.get_backtrace

Sourceclass logger : Logger.facil -> object ... end
Sourceval from : string -> logger
Sourceval self : logger

internal logging facility

Sourceval main : logger

general logging facility

Sourceval reopen : string option -> unit

reopen log file

Sourceval log_start : float ref
Sourceval cur_size : int ref
OCaml

Innovation. Community. Security.