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.
option() = {depth, integer()} | {lists_as_strings, boolean()} | {force_strings, boolean()}
options() = [option()]
format/3 | |
format/4 | |
fprint/2 | Returns an flattened list containing the ASCII representation of the given term. |
fprint/3 | Returns an flattened list containing the ASCII representation of the given term. |
perf/0 | |
perf/3 | |
perf1/0 | |
print/2 | Returns {List, Length}. |
print/3 | Returns {List, Length}. |
safe/2 | Same as print, but never crashes. |
test/0 | |
test/2 |
format(Fmt, Args, Max) -> any()
format(Fmt, Args, Max, Options) -> any()
fprint(Term::term(), Max::pos_integer()) -> string()
Returns an flattened list containing the ASCII representation of the given term.
fprint(T::term(), Max::pos_integer(), Options::options()) -> string()
Returns an flattened list containing the ASCII representation of the given term.
perf() -> ok
perf(M::atom(), F::atom(), Reps::integer()) -> done
perf1() -> {non_neg_integer(), non_neg_integer()}
print(Term::term(), Max::pos_integer()) -> {iolist(), pos_integer()}
Returns {List, Length}
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(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() -> ok
test(Mod::atom(), Func::atom()) -> ok
Generated by EDoc