summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@apple.com>2011-05-19 14:34:39 -0700
committerJeremy Huddleston <jeremyhu@apple.com>2011-05-22 11:17:59 -0700
commit96ac4e61f4618332d95d1fd0e4799dd82844f90f (patch)
treeede9c2201fc0a4f49188733163e0e020861367dc
parent384eb45b944a4386eae74a5503423c13b5f2a659 (diff)
XQuartz: Update DEBUG_LOG to report to ASL
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
-rw-r--r--hw/xquartz/darwin.c29
-rw-r--r--hw/xquartz/darwin.h15
-rw-r--r--hw/xquartz/mach-startup/bundle-main.c3
-rw-r--r--hw/xquartz/man/Xquartz.man6
-rw-r--r--hw/xquartz/xpr/xprScreen.c2
5 files changed, 38 insertions, 17 deletions
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 50234f243..e90c33ec2 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -60,6 +60,7 @@
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
+#include <stdarg.h>
#define HAS_UTSNAME 1
#include <sys/utsname.h>
@@ -76,9 +77,31 @@
#include "quartzKeyboard.h"
#include "quartz.h"
-#ifdef ENABLE_DEBUG_LOG
-FILE *debug_log_fp = NULL;
-#endif
+aslclient aslc;
+
+void debug_asl (const char *file, const char *function, int line, const char *fmt, ...) {
+ va_list args;
+ aslmsg msg = asl_new(ASL_TYPE_MSG);
+
+ if(msg) {
+ char *_line;
+
+ asl_set(msg, "File", file);
+ asl_set(msg, "Function", function);
+ asprintf(&_line, "%d", line);
+ if(_line) {
+ asl_set(msg, "Line", _line);
+ free(_line);
+ }
+ }
+
+ va_start(args, fmt);
+ asl_vlog(aslc, msg, ASL_LEVEL_DEBUG, fmt, args);
+ va_end(args);
+
+ if(msg)
+ asl_free(msg);
+}
/*
* X server shared global variables
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index 507c6f7f6..659de432c 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -32,7 +32,7 @@
#include "inputstr.h"
#include "scrnintstr.h"
#include <X11/extensions/XKB.h>
-#include <assert.h>
+#include <asl.h>
#include "darwinfb.h"
@@ -76,16 +76,9 @@ extern int darwinMainScreenY;
// bundle-main.c
extern char *bundle_id_prefix;
-#define ENABLE_DEBUG_LOG 1
+extern void debug_asl (const char *file, const char *function, int line, const char *fmt, ...) _X_ATTRIBUTE_PRINTF(4,5);
-#ifdef ENABLE_DEBUG_LOG
-extern FILE *debug_log_fp;
-#define DEBUG_LOG_NAME "x11-debug.txt"
-#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args ); fflush(debug_log_fp);
-#else
-#define DEBUG_LOG(msg, args...)
-#endif
-
-#define TRACE() DEBUG_LOG("\n")
+#define DEBUG_LOG(msg, args...) debug_asl(__FILE__, __FUNCTION__, __LINE__, msg, ##args);
+#define TRACE() DEBUG_LOG("TRACE")
#endif /* _DARWIN_H */
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 8e3437644..0e6291414 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -66,6 +66,8 @@
/* From darwinEvents.c ... but don't want to pull in all the server cruft */
void DarwinListenOnOpenFD(int fd);
+extern aslclient aslc;
+
/* Ditto, from os/log.c */
extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
extern void FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_NORETURN;
@@ -485,7 +487,6 @@ static void ensure_path(const char *dir) {
static void setup_console_redirect(const char *bundle_id) {
char *asl_sender;
char *asl_facility;
- aslclient aslc;
asprintf(&asl_sender, "%s.server", bundle_id);
assert(asl_sender);
diff --git a/hw/xquartz/man/Xquartz.man b/hw/xquartz/man/Xquartz.man
index 19e8efbad..aea56c943 100644
--- a/hw/xquartz/man/Xquartz.man
+++ b/hw/xquartz/man/Xquartz.man
@@ -111,7 +111,11 @@ In addition to this server log, XQuartz sends messages to syslogd(8) using
asl(3). These logs are sent to the __bundle_id_prefix__ facility, and you can
watch these logs using the following syslog(1) command:
.TP 8
-.B $ syslog -w -k Facility __bundle_id_prefix__
+.B $ syslog -w -k Facility eq __bundle_id_prefix__
+.PP
+or you can include extra information such as the file, line, and function where the message originated:
+.TP 8
+.B $ syslog -w -F '$(Time) $(Sender) <$(Level)> $(File):$(Line) $(Function) :: $(Message)' -k Facility eq __bundle_id_prefix__
.PP
By default, XQaurtz sets an ASL mask which prevents it from logging messages
below the ASL_LEVEL_WARNING level (meaning almost all logging is done strictly
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index f6a712906..d2968dc1e 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -253,7 +253,7 @@ xprDisplayInit(void)
{
CGDisplayCount displayCount;
- DEBUG_LOG("");
+ TRACE();
CGGetActiveDisplayList(0, NULL, &displayCount);