2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * xdm - display manager daemon
26 * $XConsortium: debug.c /main/3 1995/07/14 13:23:25 drk $
28 * Copyright 1988 Massachusetts Institute of Technology
30 * Permission to use, copy, modify, and distribute this software and its
31 * documentation for any purpose and without fee is hereby granted, provided
32 * that the above copyright notice appear in all copies and that both that
33 * copyright notice and this permission notice appear in supporting
34 * documentation, and that the name of M.I.T. not be used in advertising or
35 * publicity pertaining to distribution of the software without specific,
36 * written prior permission. M.I.T. makes no representations about the
37 * suitability of this software for any purpose. It is provided "as is"
38 * without express or implied warranty.
40 * Author: Keith Packard, MIT X Consortium
48 /* don't compile anything in this file unless this is pre-release code */
55 # define Va_start(a,b) va_start(a,b)
57 char *DisplayName=NULL;
60 /****************************************************************************
64 * Write a debug message to stderr
66 ****************************************************************************/
68 static int DoName=TRUE;
69 static int debugLevel=0;
73 BLS_ToggleDebug( int arg)
75 debugLevel = !debugLevel;
76 (void) signal(SIGHUP,BLS_ToggleDebug);
82 Debug( char *fmt, ...)
84 static int sentinel = 0;
85 static char *debugLog;
95 * open up an error log for dtgreet
97 if ((debugLog = getenv("VG_DEBUG")) == 0)
98 debugLog = "/usr/lib/X11/dt/Dtlogin/dtgreet.log";
100 if ( !freopen(debugLog,"a",stderr)) {
103 DisplayName=dpyinfo.name;
109 if ( strlen(DisplayName) > 0 && DoName)
110 fprintf(stderr, "(%s) ", DisplayName);
112 vfprintf (stderr,fmt, args);
116 * don't prepend the display name next time if this debug message
117 * does not contain a "new line" character...
120 if ( strchr(fmt,'\n') == NULL )
133 * Debug stub for product purposes