Skip to content

Add a display attribute as a fallback #2

@Michael-F-Bryan

Description

@Michael-F-Bryan

Some types don't have a slog::Value implementation and I've found this prevents me from using slog_derive as much as I'd like. Given it's not always possible to manually implement Value for a type, and that defeats a lot of the purpose behind custom derives anyway, it would be nice to have an "escape hatch" that lets you fall back to normal formatting machinery.

For example, you could add a #[slog(display)] attribute which will expand to something like ser.emit_arguments("key".into(), &format_args!("{}", self.value))?.

In the long term it'd be nice to add some sort of Value derive or even the ability to use arbitrary expressions which may themselves give you something implementing Value (e.g. #[slog(serialize = "$field.display()")]).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions