Skip to content

Add option to log PID:s #2447

@emilk

Description

@emilk

Feature Request

Add a way to enable logging the PID for each log line in tracing-subscriber.

Crates

tracing-subscriber

Motivation

Sometimes you spawn many processes in the same terminal, and want to figure out which is logging what.

Proposal

There is already .with_thread_ids(true), so I suggest adding a .with_pid(true);

A more general solution would be .with_custom_string(std::process::id().to_string()).

Alternatives

Users can already implement it with a custom formatter, but it is a lot of work and not a lot of docs.

I believe one has to write a FormatEvent via SubscriberBuilder::event_format. One can look at https://github.com/davidbarsky/tracing-glog/ and try to do something similar, but again - it is a lot of work.

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