summaryrefslogtreecommitdiffstats
path: root/multimedia/rygel/patches/030-output-to-syslog.patch
blob: 0ed15cd6796c991b37a2d7f3aad00baf9a53cbca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Take all the output and send it to syslog.
This isn't great, but it's better than sending it to the bitbucket, at least
for troubleshooting.
--- a/src/rygel/rygel-log-handler.vala
+++ b/src/rygel/rygel-log-handler.vala
@@ -56,6 +56,29 @@
     private LogHandler () {
         this.log_level_hash = new HashMap<string,LogLevelFlags> ();
 
+        string[] argv = { "/usr/bin/logger", "-t", "rygel" };
+        int logger_fd;
+
+        try {
+            GLib.Process.spawn_async_with_pipes (null,          // working_directory
+                                                 argv,
+                                                 null,          // envp
+                                                 SpawnFlags.STDOUT_TO_DEV_NULL |
+                                                 SpawnFlags.STDERR_TO_DEV_NULL,
+                                                 null,         // child_setup
+                                                 null,         // child_pid
+                                                 out logger_fd, // standard_input
+                                                 null,          // standard_output
+                                                 null);         // standard_error
+
+            Posix.dup2 (logger_fd, Posix.STDOUT_FILENO);
+            Posix.dup2 (logger_fd, Posix.STDERR_FILENO);
+            Posix.close (logger_fd);
+        } catch (Error err) {
+            warning (_("Unable to send output to /usr/bin/logger: %s"),
+                     err.message);
+        }
+
         // Get the allowed log levels from the config
         var config = MetaConfig.get_default ();
         string log_levels;