package devkit

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

Install

dune-project
 Dependency

Authors

Maintainers

Sources

1.20261006.tar.gz
md5=a39dbbce04bd5562a9b4443daf39c582
sha512=b10104b61384b2151521b785e7f3c3250134c75eae09b42cad69bc4a22a9a5e429beb891ee87cedf376c23d9c40f09d3f71c3fd48aa35df490c0f69dc17f3242

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

Sourceval facility : string -> Logger.facil
Sourceval set_filter : ?name:??? -> Logger.level -> unit
Sourceval set_loglevels : string -> unit
Sourceval set_utc : unit -> unit
Sourceval read_env_config : ?env:??? -> 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|critical[,])*

  • raises Failure

    on invalid level values of wrong format

Sourcetype 'a pr = ?rate_limit:Control.Rate_limit.t -> ?exn:exn -> ?lines:bool -> ?backtrace:bool -> ?saved_backtrace:string list -> ?ts:Time.t -> ?structured_pairs:Logger.Pairs.t -> ?pairs:Logger.Pairs.t -> ('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 if exn is given (default is false)

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

param pairs key/value pairs to add to the line, unconditionally

param structured_pairs key/value pairs to use for structured log formats only. Plain logging will discard.

Sourceval main_rate_limiter : Control.Rate_limit.t

Default rate limiter, shared between all the loggers

Sourceclass logger : ?logger:Logger.t option -> 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