GNOME Bugzilla – Bug 773092
gstinfo: Replace %p and %r in GST_DEBUG_FILE
Last modified: 2016-11-01 18:33:25 UTC
It's useful to be able to set a name pattern for GST_DEBUG_FILE so that the same environment variable can be used for multiple processes and still write to different files. Especially useful if these processes run simultaneously. %p: Replaced with PID %r: Replaced with random number %p is obviously useful. %r is useful when for instance running two processes with same PID but in different containers.
Created attachment 337840 [details] [review] gstinfo: Replace %p and %r in GST_DEBUG_FILE
Review of attachment 337840 [details] [review]: ::: gst/gstinfo.c @@ +314,3 @@ + + name = g_strdup (env); + name = _replace_pattern_in_gst_debug_file_name (name, "%p", getpid ()); Is getpid() portable? Do we need different includes, configure checks, etc for this? @@ +315,3 @@ + name = g_strdup (env); + name = _replace_pattern_in_gst_debug_file_name (name, "%p", getpid ()); + name = _replace_pattern_in_gst_debug_file_name (name, "%r", g_random_int ()); You probably want to replace this with a fixed number of digits, e.g. %08x
(In reply to Sebastian Dröge (slomo) from comment #2) > Is getpid() portable? Do we need different includes, configure checks, etc > for this? getpid() is already used in gstinfo.c by gst_debug_log_default(), so includes and checks are already taken care of. > You probably want to replace this with a fixed number of digits, e.g. %08x Not completely sure what you're asking. "%p" and "%r" is what the user would put in the env var GST_DEBUG_FILE. The patch implements the function _replace_pattern_in_gst_debug_file_name() which will replace "%p" and "%r" with a number of the format "%u". I don't think it's worth the added complexity to allow the user to specify the format string (e.g. "%08r"). Changing "%u" to something else can easily be done of course, but I think "%u" is what makes most sense if the same format is to be used for both PID and a random int, unless we want to add code to have different formats for them.
I meant always making it %08x or similar to have a constant length filename, not making it configurable :) Generally seems ok as is though, so let's go with that.
*** Bug 674930 has been marked as a duplicate of this bug. ***
commit 287645c2d7de8d1fa0c4753b479375c48c14709a Author: Stian Selnes <stian@pexip.com> Date: Thu Oct 29 22:51:18 2015 +0100 info: Replace %p and %r in GST_DEBUG_FILE It's useful to be able to set a name pattern for GST_DEBUG_FILE so that the same environment variable can be used for multiple processes and still write to different files. Especially useful if these processes run simultaneously. %p: Replaced with PID %r: Replaced with random number %p is obviously useful. %r is useful when for instance running two processes with same PID but in different containers. https://bugzilla.gnome.org/show_bug.cgi?id=773092