After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 773092 - gstinfo: Replace %p and %r in GST_DEBUG_FILE
gstinfo: Replace %p and %r in GST_DEBUG_FILE
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
unspecified
Other All
: Normal enhancement
: 1.11.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 674930 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2016-10-17 12:16 UTC by Stian Selnes (stianse)
Modified: 2016-11-01 18:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gstinfo: Replace %p and %r in GST_DEBUG_FILE (2.19 KB, patch)
2016-10-17 12:16 UTC, Stian Selnes (stianse)
committed Details | Review

Description Stian Selnes (stianse) 2016-10-17 12:16:23 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.
Comment 1 Stian Selnes (stianse) 2016-10-17 12:16:27 UTC
Created attachment 337840 [details] [review]
gstinfo: Replace %p and %r in GST_DEBUG_FILE
Comment 2 Sebastian Dröge (slomo) 2016-10-20 11:15:57 UTC
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
Comment 3 Stian Selnes (stianse) 2016-10-24 11:55:37 UTC
(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.
Comment 4 Sebastian Dröge (slomo) 2016-10-24 12:16:57 UTC
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.
Comment 5 Tim-Philipp Müller 2016-10-27 14:05:36 UTC
*** Bug 674930 has been marked as a duplicate of this bug. ***
Comment 6 Sebastian Dröge (slomo) 2016-11-01 18:33:10 UTC
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