Module lager_trunc_io

Module to print out terms for logging.

Description

Module to print out terms for logging. Limits by length rather than depth.

The resulting string may be slightly larger than the limit; the intention is to provide predictable CPU and memory consumption for formatting terms, not produce precise string lengths.

Typical use:

trunc_io:print(Term, 500).

Source license: Erlang Public License. Original author: Matthias Lang, matthias@corelatus.se

Various changes to this module, most notably the format/3 implementation were added by Andrew Thompson <andrew@basho.com>. The module has been renamed to avoid conflicts with the vanilla module.

Data Types

option()

option() = {depth, integer()} | {lists_as_strings, boolean()} | {force_strings, boolean()}

options()

options() = [option()]

Function Index

format/3
format/4
fprint/2Returns an flattened list containing the ASCII representation of the given term.
fprint/3Returns an flattened list containing the ASCII representation of the given term.
perf/0
perf/3
perf1/0
print/2Returns {List, Length}.
print/3Returns {List, Length}.
safe/2Same as print, but never crashes.
test/0
test/2

Function Details

format/3

format(Fmt, Args, Max) -> any()

format/4

format(Fmt, Args, Max, Options) -> any()

fprint/2

fprint(Term::term(), Max::pos_integer()) -> string()

Returns an flattened list containing the ASCII representation of the given term.

fprint/3

fprint(T::term(), Max::pos_integer(), Options::options()) -> string()

Returns an flattened list containing the ASCII representation of the given term.

perf/0

perf() -> ok

perf/3

perf(M::atom(), F::atom(), Reps::integer()) -> done

perf1/0

perf1() -> {non_neg_integer(), non_neg_integer()}

print/2

print(Term::term(), Max::pos_integer()) -> {iolist(), pos_integer()}

Returns {List, Length}

print/3

print(Term::term(), Max::pos_integer(), Options::options() | #print_options{depth = integer(), lists_as_strings = boolean(), force_strings = boolean()}) -> {iolist(), pos_integer()}

Returns {List, Length}

safe/2

safe(What::term(), Len::pos_integer()) -> {string(), pos_integer()} | {string()}

Same as print, but never crashes.

This is a tradeoff. Print might conceivably crash if it's asked to print something it doesn't understand, for example some new data type in a future version of Erlang. If print crashes, we fall back to io_lib to format the term, but then the formatting is depth-limited instead of length limited, so you might run out memory printing it. Out of the frying pan and into the fire.

test/0

test() -> ok

test/2

test(Mod::atom(), Func::atom()) -> ok


Generated by EDoc