package b0
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=00a6868b4dfa34565d0141b335622a81a0e8d5b9e3c6dfad025dabfa3df2db2a1302b492953bbbce30c3a4406c324fcec25250a00b38f6d18a69e15605e3b07e
doc/b0.std/B0_std/Log/index.html
Module B0_std.LogSource
Program log.
Support for program logging. Not to be used by build logic.
The module is modelled after Logs logging, see this quick introduction. It can be made to log on a Logs source, see here.
FIXME This should maybe moved to B00_ui. Make the doc self contained (cf. references to Logs). OTOH it's nice to simply open B0_std and be done.
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.
level () is the current reporting level. The initial level is set to Warning.
level_of_string s parses a level from s according to the representation of level_to_string.
Log functions
The 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.
kmsg k level m logs m with level level and continues with k.
Logging result value Error messages
if_error ~level ~use v r is:
v, ifrisOk vuseandeis logged withlevel(defaults toError), ifrisError e.
val if_error_pp :
?level:level ->
?header:string ->
'b Fmt.t ->
use:'a ->
('a, 'b) 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) result ->
('a, 'b) resultif_error_pp' is if_error_pp' wrapped by Result.ok
Timings logging
val time :
?level:level ->
('a -> (('b, Format.formatter, unit, 'a) 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
spawn_tracer level is a spawn tracer that logs with level level. If level is Log.level.Quiet this is B0_std.Os.Cmd.spawn_tracer_nop.
Log monitoring
err_count () is the number of messages logged with level Error.
warn_count () is the number of messages logged with level Warning.
Logger
The following function allows to change the logging backend. Note that in this case monitoring and level functions are no longer relevant.
The type for the basic logging function. The function is never invoked with a level of Quiet.
kmsg_default is the default logger that logs messages on Fmt.stderr except for Log.level.App level which logs on Fmt.stdout.