annotation Logbuch::Annotations::LogType

Overview

Logs instances of a class or struct, and of its subclasses, by their fields. A type is also logged by its fields when it includes Logbuch::Tracing, or when any of its fields or initialize parameters carries @[LogAs]; any other type without its own to_trace is logged with inspect.

@[LogType(lock: @lock)] converts the fields while holding the lock.

@[LogType(log: "payments")] sends the lines of the type's traced methods, and its subclasses', to another log. It takes what the log: option of Logged takes; a name that starts with a dot is below the log the type would have without it.

@[LogType(inspect: :full)] sets the detail of the inspect logbuch writes for an opted-in type without one of its own: :summary by default, :id or :full, or :off to keep Crystal's inspect. It shows the fields shown at that detail, :redacted ones as "***".

@[LogType(stacktrace: false)] on an exception class logs it, and its subclasses, without the stack trace: the error line keeps the exception's data but does not attach the exception, which formatters print with its stack trace. A subclass can set stacktrace: true again, and a traced method's @[LogError] overrides it.

Defined in:

logbuch/annotations.cr