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

Feature request: name log files based on the executable name #153

Open
izh1979 opened this issue Sep 7, 2020 · 4 comments
Open

Feature request: name log files based on the executable name #153

izh1979 opened this issue Sep 7, 2020 · 4 comments

Comments

@izh1979
Copy link

izh1979 commented Sep 7, 2020

When you are tracing multiple different processes (with -f -ff options) when trying to understand what a system does, it is difficult later to understand what log file belongs to what process. There could be an option for automatic renaming the logs based on argv[0] supplied to execve syscall. I.e. with the proposed options you would get logs named like:

  • bash-1234.log
  • cp-1235.log

To make it possible, strace needs to:

  1. read executable name at the time of attaching to some PID,
  2. on the forking and cloning inherit that name,
  3. but rename a file on execve.
@esyr
Copy link
Member

esyr commented Sep 10, 2020

This is somewhat problematic, as fork+exec essentially leads to three files in the aforementioned case: bash-1234.log, bash-1235.log, and cp-1235.log.

@izh1979
Copy link
Author

izh1979 commented Sep 20, 2020

There are several ways.

  1. A file could be named after the last execve call. I.e. if processes call execve several times, the file will be renamed on each execve. So it will be named after the last executed command.

  2. it could be named like 1235-1-bash and 1235-2-cp.

In the second case one could easily separate syscalls that were issued by one command from the syscalls of the execed command.

Also, may be it could be useful to allow specifying the file naming scheme with the printf-like syntax. I.e. --log-name=%p-%n-%c.log

@esyr
Copy link
Member

esyr commented Aug 23, 2021

Similar requests: #25 #54 #99

@ashutosh887
Copy link

I would like to work on this Issue if not resolved @esyr

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

No branches or pull requests

3 participants