XQuartz: Update DEBUG_LOG to report to ASL

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
This commit is contained in:
Jeremy Huddleston 2011-05-19 14:34:39 -07:00
parent 384eb45b94
commit 96ac4e61f4
5 changed files with 38 additions and 17 deletions

View File

@ -60,6 +60,7 @@
#include <stdio.h> #include <stdio.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <stdarg.h>
#define HAS_UTSNAME 1 #define HAS_UTSNAME 1
#include <sys/utsname.h> #include <sys/utsname.h>
@ -76,9 +77,31 @@
#include "quartzKeyboard.h" #include "quartzKeyboard.h"
#include "quartz.h" #include "quartz.h"
#ifdef ENABLE_DEBUG_LOG aslclient aslc;
FILE *debug_log_fp = NULL;
#endif 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 * X server shared global variables

View File

@ -32,7 +32,7 @@
#include "inputstr.h" #include "inputstr.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#include <X11/extensions/XKB.h> #include <X11/extensions/XKB.h>
#include <assert.h> #include <asl.h>
#include "darwinfb.h" #include "darwinfb.h"
@ -76,16 +76,9 @@ extern int darwinMainScreenY;
// bundle-main.c // bundle-main.c
extern char *bundle_id_prefix; 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 #define DEBUG_LOG(msg, args...) debug_asl(__FILE__, __FUNCTION__, __LINE__, msg, ##args);
extern FILE *debug_log_fp; #define TRACE() DEBUG_LOG("TRACE")
#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")
#endif /* _DARWIN_H */ #endif /* _DARWIN_H */

View File

@ -66,6 +66,8 @@
/* From darwinEvents.c ... but don't want to pull in all the server cruft */ /* From darwinEvents.c ... but don't want to pull in all the server cruft */
void DarwinListenOnOpenFD(int fd); void DarwinListenOnOpenFD(int fd);
extern aslclient aslc;
/* Ditto, from os/log.c */ /* Ditto, from os/log.c */
extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2); extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
extern void FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_NORETURN; 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) { static void setup_console_redirect(const char *bundle_id) {
char *asl_sender; char *asl_sender;
char *asl_facility; char *asl_facility;
aslclient aslc;
asprintf(&asl_sender, "%s.server", bundle_id); asprintf(&asl_sender, "%s.server", bundle_id);
assert(asl_sender); assert(asl_sender);

View File

@ -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 asl(3). These logs are sent to the __bundle_id_prefix__ facility, and you can
watch these logs using the following syslog(1) command: watch these logs using the following syslog(1) command:
.TP 8 .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 .PP
By default, XQaurtz sets an ASL mask which prevents it from logging messages 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 below the ASL_LEVEL_WARNING level (meaning almost all logging is done strictly

View File

@ -253,7 +253,7 @@ xprDisplayInit(void)
{ {
CGDisplayCount displayCount; CGDisplayCount displayCount;
DEBUG_LOG(""); TRACE();
CGGetActiveDisplayList(0, NULL, &displayCount); CGGetActiveDisplayList(0, NULL, &displayCount);