Reporting levels
The type for reporting levels. They are meant to be used as follows:
Quietdoesn't report anything.Appcan be used for the standard output or console of an application. Using this instead ofstdoutdirectly allows the output to be silenced byQuietwhich may be desirable, or not.Erroris an error condition that prevents the program from running.Warningis a suspicious condition that does not prevent the program from running normally but may eventually lead to an error condition.Infois a condition that allows the program user to get a better understanding of what the program is doing.Debugis a condition that allows the program developer to get a better understanding of what the program is doing.
val level : unit -> levellevel () is the current reporting level. The initial level is set to Warning.
val set_level : level -> unitset_level l sets the current reporting level to l.
val level_to_string : level -> stringlevel_to_string l converts l to a string representation.
val level_of_string : string -> (level, string) Stdlib.resultlevel_of_string s parses a level from s according to the representation of level_to_string.
Log functions
type ('a, 'b) msgf = (?header:string -> ('a, Stdlib.Format.formatter, unit, 'b) Stdlib.format4 -> 'a) -> 'bThe type for client specified message formatting functions. See Logs.msgf.
header interpretation is up to the reported but None should automatially output headers that depend on the level and Some "" should not output any header leaving full control to the client.
type 'a log = ('a, unit) msgf -> unitThe type for log functions. See Logs.log.
val quiet : 'a logquiet is msg Quiet.
val app : 'a logapp is msg App.
val err : 'a logerr is msg Error.
val warn : 'a logwarn is msg Warning.
val info : 'a loginfo is msg Info.
val debug : 'a logdebug is msg Debug.
kmsg k level m logs m with level level and continues with k.
Logging result value Error messages
val if_error : ?level:level -> ?header:string -> use:'a -> ('a, string) Stdlib.result -> 'aif_error ~level ~use v r is:
v, ifrisOk vuseandeis logged withlevel(defaults toError), ifrisError e.
val if_error' : ?level:level -> ?header:string -> use:'a -> ('a, string) Stdlib.result -> ('a, 'b) Stdlib.resultval if_error_pp : ?level:level -> ?header:string -> 'b Fmt.t -> use:'a -> ('a, 'b) Stdlib.result -> 'aif_error_pp ~level pp ~use r is
v, ifrisOk v.useandeis logged withlevel(defaults toError) usingpp, ifrisError e.
val if_error_pp' : ?level:level -> ?header:string -> 'b Fmt.t -> use:'a -> ('a, 'b) Stdlib.result -> ('a, 'b) Stdlib.resultif_error_pp' is if_error_pp' wrapped by Result.ok
Timings logging
val time : ?level:level -> ('a -> (('b, Stdlib.Format.formatter, unit, 'a) Stdlib.format4 -> 'b) -> 'a) -> (unit -> 'a) -> 'atime ~level m f logs m with level level (defaults to Info) and the time f () took as the log header.
Note. The current log level is determined after f has been called this means f can change it to affect the log operation. This allows f to be the main function of your program and let it set the log level.
Spawn logging
val spawn_tracer : level -> Os.Cmd.spawn_tracerspawn_tracer level is a spawn tracer that logs with level level. If level is Log.level.Quiet this is B00_std.Os.Cmd.spawn_tracer_nop.
Log monitoring
Logger
The type for the basic logging function. The function is never invoked with a level of Quiet.
val kmsg_nop : kmsgnop_kmsg is a logger that does nothing.
val kmsg_default : kmsgkmsg_default is the default logger that logs messages on Fmt.stderr except for Log.level.App level which logs on Fmt.stdout.
val set_kmsg : kmsg -> unitset_kmsg kmsg sets the logging function to kmsg.