package lucid

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Lucid is a super simple logging library.

Log Levels

type level =
  1. | Output
  2. | Debug
  3. | Info
  4. | Warn
  5. | Error
  6. | Fatal
val level_to_string : level option -> string

Converts Level to String

val level_of_string : string -> (level option, string) Stdlib.result

Converts String to Level

val level_to_int : level option -> int

Converts Level to Int

Debug -> 1
Info -> 2
Warn -> 3
Error -> 4
Fatal -> 5
val level_of_int : int -> (level option, string) Stdlib.result

Converts Int to level

val set_level : level -> unit

set_level Warn will set enable logging for Warn and the levels above it.

val get_level : unit -> level

Returns the lowest level being logged.

Timestamp

type timezone =
  1. | Local
  2. | GMT
  3. | None
val set_tz : timezone -> unit

set_tz GMT will set the timestamp timezone to GMT.

val get_tz : unit -> timezone

Returns the timezone being used for the timestamp.

val disable_tz : unit -> unit

Disables timestamps, timestamps can be enabled again using set_tz.

Log Functions

val debug : string -> unit

debug "message" will log message with the level Debug.

val info : string -> unit

info "message" will log message with the level Info.

val warn : string -> unit

warn "message" will log message with the level Warn.

val error : string -> unit

error "message" will log message with the level Error.

val fatal : string -> unit

fatal "message" will log message with the level Fatal.

val critical : string -> unit

Same as fatal

critical "message" will log message with the level Fatal.

Output Channel

val set_out_channel : Stdlib.out_channel -> unit
val get_out_channel : unit -> Stdlib.out_channel

Colors

type color =
  1. | Black
  2. | Red
  3. | Green
  4. | Yellow
  5. | Blue
  6. | Magenta
  7. | Cyan
  8. | White
  9. | Custom of int
val set_color_fg : clr:color -> lvl:level -> unit

Set foreground color of the logging label for a certain level.

val set_color_fg_brt : clr:color -> lvl:level -> unit

Same as set_color_fg but uses bright colors.

val set_color_bg : clr:color -> lvl:level -> unit

Set background color of the logging label for a certain level.

val set_color_bg_brt : clr:color -> lvl:level -> unit

Same as set_color_bg but uses bright colors.

val get_color : level -> string * string

get_color Error will return a 2-tuple string * string where the first string corresponds to the foreground color of the level Error and second to the background color.

Counters

val get_count : level -> int

Gets the number of times a certain level has been successfully called to log.

val get_count_logged : level -> int

Gets the number of times a certain level has actually logged.

val get_count_unlogged : level -> int

get_count - get_count_logged

val set_count : lvl:level -> int -> unit
val set_count_logged : lvl:level -> int -> unit
val count_total : unit -> int
val count_total_logged : unit -> int