Re: [PATCH 2/2] trace2: randomize/timestamp trace2 targets
- Date: Wed, 13 Mar 2019 20:16:01 -0400
- From: Jeff King <peff@xxxxxxxx>
- Subject: Re: [PATCH 2/2] trace2: randomize/timestamp trace2 targets
On Wed, Mar 13, 2019 at 04:33:29PM -0700, Josh Steadmon wrote:
> When the value of a trace2 environment variable contains instances of
> the string "%ISO8601%", expand them into the current UTC timestamp in
> ISO 8601 format.
This definitely seems useful. Could we drop the final "%" and make it
either a single-character "%t" or "%(iso8601)" to match our other
formatting strings? There's no _technical_ reason to do that, but it
just seems like there's not much point in being unnecessarily
> When the value of a trace2 environment variable is an absolute path
> referring to an existing directory, write output to randomly-named
> files under the given directory. If the value is an absolute path
> referring to a non-existent file and ends with a dash, use the value as
> a prefix for randomly named files.
> The random filenames will consist of the value of the environment
> variable (after potential timestamp expansion), followed by a 6
> character random string such as would be produced by mkstemp(3).
Doing this automatically for directories feels kind of magical. I'd have
expected it to be just another placeholder. And in fact, I'd think using
the process id as a placeholder would be pretty common. Between
timestamp and pid, that's generally unique (though I'm not opposed to
the random placeholder if somebody really wants to be thorough).
That leaves the door open for being able to append to or overwrite
existing trace files later, if we want to make that a possibility.