Minidebug_runtime
The functors creating a Debug_runtime
module that ppx_minidebug
requires.
type log_level =
| Nothing
Does not log anything.
*)| Prefixed of string array
Behaves as Nonempty_entries
and additionally: only logs "leaf" values when the inspected string starts with one of the prefixes.
| Prefixed_or_result of string array
Behaves as Nonempty_entries
and additionally: only logs "leaf" values when the inspected string starts with one of the prefixes, or the value is marked as a result. Doesn't output results of an entry if there are no non-result logs.
| Nonempty_entries
Does not log entries without children (treating results as children).
*)| Everything
Does not restrict logging.
*)The log levels, for both (in scope) compile time, and for the PrintBox runtime. When considered at compile time, inspecting strings requires string literals, at runtime it applies to all string values. Not logging at compile time means the corresponding loggingcode is not generated; not logging at runtime means the logging state is not updated.
type toc_entry_criteria =
| Minimal_depth of int
| Minimal_size of int
| Minimal_span of Mtime.span
| And of toc_entry_criteria list
| Or of toc_entry_criteria list
Sets up a file with the given path, or if split_files_after
is given, creates a directory to store the files. By default the logging will not be time tagged and will be appending to the file / creating more files. If time_tagged
is Clock
, entries will be tagged with a date and clock time; if it is Elapsed
, they will be tagged with the time span elapsed since the start of the process (using Mtime_clock.elapsed
). If split_files_after
is given and for_append
is false, clears the directory. If the opened file exceeds split_files_after
characters, Shared_config.refresh_ch ()
returns true; if in that case Shared_config.debug_ch ()
is called, it will create and return a new file.
If elapsed_times
is different from Not_reported
, the elapsed time spans are printed for log subtrees, in the corresponding units with precision up to 1%. The times include printing out logs, therefore might not be reliable for profiling. In the runtime creation functions, elapsed_times
defaults to Not_reported
.
If print_entry_ids
is true, the entry_id
identifiers are printed on log headers with the syntax {#ID}
; by default they are omitted. If verbose_entry_ids
is true, the entry_id
identifiers are also printed on logged values.
If global_prefix
is given, the log header messages (and the log closing messages for the flushing backend) are prefixed with it.
If table_of_contents_ch
is given or with_table_of_contents=true
, outputs selected log headers to this channel. The provided file name is used as a prefix for links to anchors of the log headers. Note that debug runtime builders that take a channel instead of a file name, will use global_prefix
instead for the anchor links. The setting toc_entry
controls the selection of headers to include in a ToC (it defaults to And []
, which means including all entries).
module type Debug_runtime = sig ... end
When using the ppx_minidebug
syntax extension, provide a module called Debug_runtime
with this signature in scope of the instrumented code.
module Flushing (_ : Shared_config) : Debug_runtime
The output is flushed line-at-a-time, so no output should be lost if the traced program crashes. The logged traces are still indented, but if the values to print are multi-line, their formatting might be messy. The indentation is also smaller (half of PrintBox).
module type PrintBox_runtime = sig ... end
module PrintBox (_ : Shared_config) : PrintBox_runtime
The logged traces will be pretty-printed as trees using the `printbox` package. This logger supports conditionally disabling a particular nesting of the logs, regardless of where in the nesting level no_debug_if
is called.
val debug_file :
?time_tagged:time_tagged ->
?elapsed_times:elapsed_times ->
?location_format:location_format ->
?print_entry_ids:bool ->
?verbose_entry_ids:bool ->
?global_prefix:string ->
?split_files_after:int ->
?with_toc_listing:bool ->
?toc_entry:toc_entry_criteria ->
?toc_flame_graph:bool ->
?flame_graph_separation:int ->
?highlight_terms:Re.t ->
?exclude_on_path:Re.t ->
?prune_upto:int ->
?truncate_children:int ->
?for_append:bool ->
?boxify_sexp_from_size:int ->
?max_inline_sexp_length:int ->
?backend:
[ `Text
| `Html of PrintBox_html.Config.t
| `Markdown of PrintBox_md.Config.t ] ->
?hyperlink:string ->
?toc_specific_hyperlink:string ->
?values_first_mode:bool ->
?log_level:log_level ->
?snapshot_every_sec:float ->
string ->
(module PrintBox_runtime)
Creates a PrintBox-based debug runtime configured to output html or markdown to a file with the given name suffixed with ".log"
, ".html"
or ".md"
depending on the backend. By default the logging will not be time tagged and the file will be created or erased by this function. The default boxify_sexp_from_size
value is 50.
Setting ~with_toc_listing:true
or ~toc_flame_graph:true
or both will create an additional log file, the given name suffixed with "-toc"
and the corresponding file name extension. This file will collect selected entries, hyperlinking to anchors in the main logging file(s).
By default backend
is `Markdown PrintBox.default_md_config
. See PrintBox.config
for details about PrintBox-specific parameters. See shared_config
for the details about shared parameters.
val debug :
?debug_ch:Stdlib.out_channel ->
?time_tagged:time_tagged ->
?elapsed_times:elapsed_times ->
?location_format:location_format ->
?print_entry_ids:bool ->
?verbose_entry_ids:bool ->
?global_prefix:string ->
?table_of_contents_ch:Stdlib.out_channel ->
?toc_entry:toc_entry_criteria ->
?highlight_terms:Re.t ->
?exclude_on_path:Re.t ->
?prune_upto:int ->
?truncate_children:int ->
?toc_specific_hyperlink:string ->
?values_first_mode:bool ->
?log_level:log_level ->
?snapshot_every_sec:float ->
unit ->
(module PrintBox_runtime)
Creates a PrintBox-based debug runtime for the `Text
backend. By default it will log to stdout
and will not be time tagged.
See PrintBox.config
for details about PrintBox-specific parameters. See shared_config
for the details about shared parameters.
val debug_flushing :
?debug_ch:Stdlib.out_channel ->
?table_of_contents_ch:Stdlib.out_channel ->
?filename:string ->
?time_tagged:time_tagged ->
?elapsed_times:elapsed_times ->
?location_format:location_format ->
?print_entry_ids:bool ->
?verbose_entry_ids:bool ->
?global_prefix:string ->
?split_files_after:int ->
?with_table_of_contents:bool ->
?toc_entry:toc_entry_criteria ->
?for_append:bool ->
unit ->
(module Debug_runtime)
Creates a flushing-based debug runtime. By default it will log to stdout
and will not be time tagged. At most one of debug_ch
, filename
can be provided. Adds the suffix ".log"
to the file name if filename
is given.
See shared_config
for the details about shared parameters.
val forget_printbox : (module PrintBox_runtime) -> (module Debug_runtime)
Upcasts the runtime.