Prior to allowing multiple log sinks, first allow logging to a file on
disk to be disabled.

Signed-off-by: William Douglas <[email protected]>
---
 configure.ac             | 9 +++++++++
 include/xorg-config.h.in | 3 +++
 os/log.c                 | 8 ++++++++
 3 files changed, 20 insertions(+)

diff --git a/configure.ac b/configure.ac
index 5159420..68b8762 100644
--- a/configure.ac
+++ b/configure.ac
@@ -476,6 +476,10 @@ AC_ARG_WITH(module-dir,      
AS_HELP_STRING([--with-module-dir=DIR],
                                  [Directory where modules are installed 
(default: $libdir/xorg/modules)]),
                                [ moduledir="$withval" ],
                                [ moduledir="${libdir}/xorg/modules" ])
+AC_ARG_ENABLE(filesystem-logging, 
AS_HELP_STRING([--disable-filesystem-logging],
+                                 [Write log messages to the filesystem 
(default: enabled)]),
+                               [ FILESYSTEM_LOGGING=$enableval ],
+                               [ FILESYSTEM_LOGGING=yes ])
 AC_ARG_WITH(log-dir,         AS_HELP_STRING([--with-log-dir=DIR],
                                  [Directory where log files are kept (default: 
$localstatedir/log)]),
                                [ logdir="$withval" ],
@@ -1483,6 +1487,11 @@ AC_MSG_RESULT([$with_sha1])
 AC_SUBST(SHA1_LIBS)
 AC_SUBST(SHA1_CFLAGS)
 
+AM_CONDITIONAL(FILESYSTEM_LOGGING, [test "x$FILESYSTEM_LOGGING" = xyes])
+if test "x$FILESYSTEM_LOGGING" = xyes; then
+       AC_DEFINE(FILESYSTEM_LOGGING, 1, [Write log messages to the filesystem])
+fi
+
 PKG_CHECK_MODULES([XSERVERCFLAGS], [$REQUIRED_MODULES $REQUIRED_LIBS])
 PKG_CHECK_MODULES([XSERVERLIBS], [$REQUIRED_LIBS])
 
diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in
index 0df31ae..93027c5 100644
--- a/include/xorg-config.h.in
+++ b/include/xorg-config.h.in
@@ -142,4 +142,7 @@
 /* Define to 1 if you have the `seteuid' function. */
 #undef HAVE_SETEUID
 
+/* Use filesystem logging */
+#undef FILESYSTEM_LOGGING
+
 #endif /* _XORG_CONFIG_H_ */
diff --git a/os/log.c b/os/log.c
index 53b3586..856fa0f 100644
--- a/os/log.c
+++ b/os/log.c
@@ -192,6 +192,7 @@ strlen_sigsafe(const char *s)
 const char *
 LogInit(const char *fname, const char *backup)
 {
+#ifdef FILESYSTEM_LOGGING
     char *logFileName = NULL;
 
     if (fname && *fname) {
@@ -234,6 +235,7 @@ LogInit(const char *fname, const char *backup)
 #endif
         }
     }
+#endif
 
     /*
      * Unconditionally free the buffer, and flag that the buffer is no longer
@@ -246,12 +248,17 @@ LogInit(const char *fname, const char *backup)
     }
     needBuffer = FALSE;
 
+#ifdef FILESYSTEM_LOGGING
     return logFileName;
+#else
+    return NULL;
+#endif
 }
 
 void
 LogClose(enum ExitCode error)
 {
+#ifdef FILESYSTEM_LOGGING
     if (logFile) {
         ErrorFSigSafe("Server terminated %s (%d). Closing log file.\n",
                (error == EXIT_NO_ERROR) ? "successfully" : "with error", 
error);
@@ -259,6 +266,7 @@ LogClose(enum ExitCode error)
         logFile = NULL;
         logFileFd = -1;
     }
+#endif
 }
 
 Bool
-- 
1.8.3.4

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to