module Logbuch
Overview
Method tracing for Crystal.
Defined in:
logbuch.crlogbuch/annotations.cr
logbuch/convert.cr
logbuch/detail.cr
logbuch/fiber_state.cr
logbuch/field_rules.cr
logbuch/limits.cr
logbuch/line_data.cr
logbuch/locks.cr
logbuch/logs.cr
logbuch/messages.cr
logbuch/settings.cr
logbuch/tracer.cr
logbuch/tracing.cr
logbuch/values.cr
Constant Summary
-
DEPTH_CEILING =
256_u32 -
The deepest any traced value nests, also through a
Logbuch.convertin ato_trace, so converting it neither overflows the stack nor grows the tracer's path without bound. Amax_depthabove it fails to compile or raises. -
MAX_CAP =
100_u32 -
Items logged from one collection; the rest are counted.
-
MAX_DEPTH =
16_u32 -
Nesting depth of objects, structs and collections in one traced value; deeper ones are logged as their identity, such as
"o-17". SeeTracerfor the values that take a level. -
MAX_LENGTH =
1024_u32 -
Characters logged from one string; the rest are counted.
-
VERSION =
{{ (`shards version \"/home/runner/work/logbuch/logbuch/src/..\"`).chomp.stringify }} -
The shard's version, which
shards versionreads from itsshard.ymlwhen the program compiles.
Class Method Summary
-
.convert(value, *, detail : Detail = Detail::Summary) : Log::Metadata::Value
Converts value into trace data at detail, as a traced method logs it.
-
.settings : Settings
The settings in effect.
Macro Summary
-
configure(&block)
Changes the settings: the block runs with a
Configurationas its receiver, and the settings it names change, the others stay.
Class Method Detail
Converts value into trace data at detail, as a traced method logs it.
At Detail::Omit it converts to nil.
Logbuch.convert(order, detail: :full)
The settings in effect. The first call reads the environment variables,
unless configure came first.
A program built with -Dlogbuch=off gets the defaults, MAX_DEPTH,
MAX_CAP and MAX_LENGTH, whatever configure sets: it reads no
variable and keeps no state.
Macro Detail
Changes the settings: the block runs with a Configuration as its
receiver, and the settings it names change, the others stay. Returns the
settings in effect afterwards, which apply to the conversions that start
after it returns.
Logbuch.configure do
max_depth 3
max_cap 50
end
An environment variable that is set to a valid value, such as
LOGBUCH_MAX_DEPTH=8, overrides the value set in code unless the block
switches it off. A value out of range raises ArgumentError, and a block
that raises changes nothing. A setter called directly in the block with an
integer literal out of range, such as max_depth 300 or max_cap -1,
fails the build instead.
It is a macro, so that a program built with -Dlogbuch=off compiles
nothing of it. There it only type-checks the block, so a block that does
not compile fails that build too, but never runs it, so nothing else the
block does happens either; it returns the defaults, as .settings does,
and does not check a value that is not a literal.