package pplumbing

  1. Overview
  2. Docs
Utility libraries to use with [pp]

Install

Dune Dependency

Authors

Maintainers

Sources

pplumbing-0.0.14.tbz
sha256=ed7eaba180378a59719e9af63ccdc89dde8e0a20f2cba420abb0080b0bc4a868
sha512=f168c37c1acd38c92e5b6d59321da4021195b6ddc49dde82de70e9282b55042621bea1b84a677d57f83604c06d6ee9c790b683fd589cd2097ab8f00c293f56af

doc/pplumbing.log/Log/index.html

Module LogSource

An interface to Logs using Pp_tty.

This module can be used in places where you'd use functions from Logs when you wish to build your formatted document with Pp_tty rather than with Format.

For example:

  let hello ?src () =
    Log.info ?src (fun () -> [ Pp.textf "Hello %s World!" "Friendly" ])
  ;;

Styles may be injected in the document using Pp_tty. For example:

  let hello ?src () =
    Log.info ?src (fun () ->
      [ Pp.concat
          ~sep:Pp.space
          [ Pp.text "Hello"
          ; Pp_tty.tag (Ansi_styles [ `Fg_blue ]) (Pp.verbatim "Colored")
          ; Pp.text "World!"
          ]
      ])
  ;;

Logs types aliases

Sourcetype level = Logs.level
Sourcetype src = Logs.src

Logging functions

Log interface

We've looked through sherlocode to get some sense of how the Logs interface is used. In the most common cases, the function m is applied directly without header nor tags. When the headers or tags are used, they are usually constant values for headers, and for tags, either a constant or a function from unit to tags, applied in the body of m.

Based on this remarks and on the fact that we don't need a format string anymore, we've proposed an interface where the m auxiliary function is removed.

We this interface, the previous example can be written as:

  let hello ?src ?header ?tags () =
    Log.info ?src ?header ?tags (fun () ->
      [ Pp.concat
          ~sep:Pp.space
          [ Pp.text "Hello"
          ; Pp_tty.tag (Ansi_styles [ `Fg_blue ]) (Pp.verbatim "Colored")
          ; Pp.text "World!"
          ]
      ])
  ;;
Sourcetype log = ?header:string -> ?tags:(unit -> Logs.Tag.set) -> (unit -> Pp_tty.t list) -> unit
Sourceval msg : ?src:src -> level -> log
Sourceval app : ?src:src -> log
Sourceval err : ?src:src -> log
Sourceval warn : ?src:src -> log
Sourceval info : ?src:src -> log
Sourceval debug : ?src:src -> log

Logs Interface

Sourcemodule Logs : sig ... end

Interface in the style of Logs.

OCaml

Innovation. Community. Security.