Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to log PID:s #2447

Open
emilk opened this issue Jan 19, 2023 · 1 comment · May be fixed by #2655
Open

Add option to log PID:s #2447

emilk opened this issue Jan 19, 2023 · 1 comment · May be fixed by #2655

Comments

@emilk
Copy link
Sponsor

emilk commented Jan 19, 2023

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.

@davidbarsky
Copy link
Member

I think that in the short term, we can and should add it to fmt::Layer/fmt::Subscriber, but longer term, I'd like to figure out how to share configuration between formatters.

nicolasavru added a commit to nicolasavru/tracing that referenced this issue Jul 16, 2023
These options are useful when multiple processes are logging to the same
destination (stderr, in the common case). This can happen when a process
launches a child process or when a user simply launches multiple
processes in the same terminal.

Fixes tokio-rs#2447.
nicolasavru added a commit to nicolasavru/tracing that referenced this issue Jul 16, 2023
These options are useful when multiple processes are logging to the same
destination (stderr, in the common case). This can happen when a process
launches a child process or when a user simply launches multiple
processes in the same terminal.

Fixes tokio-rs#2447.

Implement these two options.
nicolasavru added a commit to nicolasavru/tracing that referenced this issue Jul 16, 2023
These options are useful when multiple processes are logging to the same
destination (stderr, in the common case). This can happen when a process
launches a child process or when a user simply launches multiple
processes in the same terminal.

Fixes tokio-rs#2447.

Implement these two options.
nicolasavru added a commit to nicolasavru/tracing that referenced this issue Jul 17, 2023
These options are useful when multiple processes are logging to the same
destination (stderr, in the common case). This can happen when a process
launches a child process or when a user simply launches multiple
processes in the same terminal.

Fixes tokio-rs#2447.

Implement these two options.
nicolasavru added a commit to nicolasavru/tracing that referenced this issue Jul 10, 2024
These options are useful when multiple processes are logging to the same
destination (stderr, in the common case). This can happen when a process
launches a child process or when a user simply launches multiple
processes in the same terminal.

Fixes tokio-rs#2447.

Implement these two options.
nicolasavru added a commit to nicolasavru/tracing that referenced this issue Jul 10, 2024
These options are useful when multiple processes are logging to the same
destination (stderr, in the common case). This can happen when a process
launches a child process or when a user simply launches multiple
processes in the same terminal.

Fixes tokio-rs#2447.

Implement these two options.
nicolasavru added a commit to nicolasavru/tracing that referenced this issue Jul 10, 2024
These options are useful when multiple processes are logging to the same
destination (stderr, in the common case). This can happen when a process
launches a child process or when a user simply launches multiple
processes in the same terminal.

Fixes tokio-rs#2447.

Implement these two options.
nicolasavru added a commit to nicolasavru/tracing that referenced this issue Jul 10, 2024
These options are useful when multiple processes are logging to the same
destination (stderr, in the common case). This can happen when a process
launches a child process or when a user simply launches multiple
processes in the same terminal.

Fixes tokio-rs#2447.

Implement these two options.
nicolasavru added a commit to nicolasavru/tracing that referenced this issue Jul 10, 2024
These options are useful when multiple processes are logging to the same
destination (stderr, in the common case). This can happen when a process
launches a child process or when a user simply launches multiple
processes in the same terminal.

Fixes tokio-rs#2447.

Implement these two options.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants