slog icon indicating copy to clipboard operation
slog copied to clipboard

BROKEN: Attempt to support #[track_caller]

Open Techcable opened this issue 6 months ago • 0 comments

Attempt to fix issue #342

Due to the need to create &'static RecordStatic at compile time, this is much more difficult than adding support in the log crate.

I tried various combination of inline const and const declaration. In each case, the track_caller::track_caller test failed to respect the #[track_caller] attribute.

~~It turns out that there is a bizarre interaction that means Location::caller does not respect #[track_caller] in a const-eval context.~~

EDIT: This is not a "bizzare interaction", it is a fundamental limitation of const-eval.

See here for a demo: https://gist.github.com/Techcable/a80e3a4c4d928a2038dc45bd6d91f9e4 You can also run this in the playground.

A workaround would be adding a &'static Location to the slog::Record struct, but this would add another pointer to the record and possibly break backwards compatibility.

Techcable avatar Aug 27 '25 08:08 Techcable