~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Frontier Kernel
Frontier/Common/source/frontierdebug.c

Version: ~ [ 10.0 ] ~

** Warning: Cannot open xref database.

1 2 /* $Id: frontierdebug.c,v 1.4 2005/01/11 22:48:05 andreradke Exp $ */ 3 4 /****************************************************************************** 5 6 UserLand Frontier(tm) -- High performance Web content management, 7 object database, system-level and Internet scripting environment, 8 including source code editing and debugging. 9 10 Copyright (C) 1992-2004 UserLand Software, Inc. 11 12 This program is free software; you can redistribute it and/or modify 13 it under the terms of the GNU General Public License as published by 14 the Free Software Foundation; either version 2 of the License, or 15 (at your option) any later version. 16 17 This program is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 GNU General Public License for more details. 21 22 You should have received a copy of the GNU General Public License 23 along with this program; if not, write to the Free Software 24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 26 ******************************************************************************/ 27 28 #include "frontier.h" 29 #include "standard.h" 30 31 #include "about.h" 32 #include "frontierdebug.h" 33 #include "process.h" 34 #include "processinternal.h" 35 #include "strings.h" 36 37 38 static const char debuglogname[] = "frontierdebuglog.txt"; 39 40 static FILE * logfile = nil; 41 42 static boolean flreentering = false; 43 44 45 /* compiler messages for GENERAL category */ 46 47 #if (LAND_GENERALLOG_LEVEL >= LAND_LOGLEVEL_3) 48 #pragma message ("*********************** GENERAL LOG: Level 3") 49 #elif (LAND_GENERALLOG_LEVEL >= LAND_LOGLEVEL_2) 50 #pragma message ("*********************** GENERAL LOG: Level 2") 51 #elif (LAND_GENERALLOG_LEVEL >= LAND_LOGLEVEL_1) 52 #pragma message ("*********************** GENERAL LOG: Level 1") 53 #else 54 #pragma message ("*********************** GENERAL LOG: --OFF--") 55 #endif 56 57 #if (LAND_GENERALLOG_LEVEL > LAND_LOGLEVEL_OFF) 58 #if (LAND_GENERALLOG_TARGET & LAND_LOGTARGET_FILE) 59 #pragma message ("*********************** GENERAL LOG: output to FILE") 60 #endif 61 #if (LAND_GENERALLOG_TARGET & LAND_LOGTARGET_ABOUT) 62 #pragma message ("*********************** GENERAL LOG: output to ABOUT WINDOW") 63 #endif 64 #if (LAND_GENERALLOG_TARGET & LAND_LOGTARGET_DIALOG) 65 #pragma message ("*********************** GENERAL LOG: output to DIALOG") 66 #endif 67 #if (LAND_GENERALLOG_TARGET & LAND_LOGTARGET_DEBUGGER) 68 #pragma message ("*********************** GENERAL LOG: output to DEBUGGER") 69 #endif 70 #endif 71 72 73 /* compiler messages for TCP category */ 74 75 #if (LAND_TCPLOG_LEVEL >= LAND_LOGLEVEL_3) 76 #pragma message ("*********************** TCP LOG: Level 3") 77 #elif (LAND_TCPLOG_LEVEL >= LAND_LOGLEVEL_2) 78 #pragma message ("*********************** TCP LOG: Level 2") 79 #elif (LAND_TCPLOG_LEVEL >= LAND_LOGLEVEL_1) 80 #pragma message ("*********************** TCP LOG: Level 1") 81 #else 82 #pragma message ("*********************** TCP LOG: --OFF--") 83 #endif 84 85 #if (LAND_TCPLOG_LEVEL > LAND_LOGLEVEL_OFF) 86 #if (LAND_TCPLOG_TARGET & LAND_LOGTARGET_FILE) 87 #pragma message ("*********************** TCP LOG: output to FILE") 88 #endif 89 #if (LAND_TCPLOG_TARGET & LAND_LOGTARGET_ABOUT) 90 #pragma message ("*********************** TCP LOG: output to ABOUT WINDOW") 91 #endif 92 #if (LAND_TCPLOG_TARGET & LAND_LOGTARGET_DIALOG) 93 #pragma message ("*********************** TCP LOG: output to DIALOG") 94 #endif 95 #if (LAND_TCPLOG_TARGET & LAND_LOGTARGET_DEBUGGER) 96 #pragma message ("*********************** TCP LOG: output to DEBUGGER") 97 #endif 98 #endif 99 100 101 /* compiler messages for DB category */ 102 103 #if (LAND_DBLOG_LEVEL >= LAND_LOGLEVEL_3) 104 #pragma message ("*********************** DB LOG: Level 3") 105 #elif (LAND_DBLOG_LEVEL >= LAND_LOGLEVEL_2) 106 #pragma message ("*********************** DB LOG: Level 2") 107 #elif (LAND_DBLOG_LEVEL >= LAND_LOGLEVEL_1) 108 #pragma message ("*********************** DB LOG: Level 1") 109 #else 110 #pragma message ("*********************** DB LOG: --OFF--") 111 #endif 112 113 #if (LAND_DBLOG_LEVEL > LAND_LOGLEVEL_OFF) 114 #if (LAND_DBLOG_TARGET & LAND_LOGTARGET_FILE) 115 #pragma message ("*********************** DB LOG: output to FILE") 116 #endif 117 #if (LAND_DBLOG_TARGET & LAND_LOGTARGET_ABOUT) 118 #pragma message ("*********************** DB LOG: output to ABOUT WINDOW") 119 #endif 120 #if (LAND_DBLOG_TARGET & LAND_LOGTARGET_DIALOG) 121 #pragma message ("*********************** DB LOG: output to DIALOG") 122 #endif 123 #if (LAND_DBLOG_TARGET & LAND_LOGTARGET_DEBUGGER) 124 #pragma message ("*********************** DB LOG: output to DEBUGGER") 125 #endif 126 #endif 127 128 129 /* compiler messages for THREADS category */ 130 131 #if (LAND_THREADSLOG_LEVEL >= LAND_LOGLEVEL_3) 132 #pragma message ("*********************** THREADS LOG: Level 3") 133 #elif (LAND_THREADSLOG_LEVEL >= LAND_LOGLEVEL_2) 134 #pragma message ("*********************** THREADS LOG: Level 2") 135 #elif (LAND_THREADSLOG_LEVEL >= LAND_LOGLEVEL_1) 136 #pragma message ("*********************** THREADS LOG: Level 1") 137 #else 138 #pragma message ("*********************** THREADS LOG: --OFF--") 139 #endif 140 141 #if (LAND_THREADSLOG_LEVEL > LAND_LOGLEVEL_OFF) 142 #if (LAND_THREADSLOG_TARGET & LAND_LOGTARGET_FILE) 143 #pragma message ("*********************** THREADS LOG: output to FILE") 144 #endif 145 #if (LAND_THREADSLOG_TARGET & LAND_LOGTARGET_ABOUT) 146 #pragma message ("*********************** THREADS LOG: output to ABOUT WINDOW") 147 #endif 148 #if (LAND_THREADSLOG_TARGET & LAND_LOGTARGET_DIALOG) 149 #pragma message ("*********************** THREADS LOG: output to DIALOG") 150 #endif 151 #if (LAND_THREADSLOG_TARGET & LAND_LOGTARGET_DEBUGGER) 152 #pragma message ("*********************** THREADS LOG: output to DEBUGGER") 153 #endif 154 #endif 155 156 157 /* functions */ 158 159 #ifdef WIN95VERSION 160 extern DWORD ixthreadglobalsgrabcount; 161 #endif 162 163 static void logtofile (char *str, char *category) { 164 165 unsigned long ticks = gettickcount (); 166 static unsigned long lastticks = 0; 167 #ifdef WIN95VERSION 168 DWORD idthread = GetCurrentThreadId(); 169 static DWORD idlastthread = 0; 170 long grabcount = (long) TlsGetValue (ixthreadglobalsgrabcount); 171 #endif 172 #ifdef MACVERSION 173 long idthread = (long) (**getcurrentthread ()).idthread; 174 static long idlastthread = 0; 175 #endif 176 177 if (logfile == NULL) { 178 logfile = fopen (debuglogname, "a"); 179 } 180 181 if (idthread != idlastthread) { 182 fprintf (logfile, "\n"); 183 idlastthread = idthread; 184 } 185 186 #ifdef WIN95VERSION 187 fprintf (logfile, "%08X (%04ld) | %04X (%02ld) | %s | &s\n", (unsigned long) ticks, (ticks - lastticks), idthread, grabcount, category, str); 188 #endif 189 190 #ifdef MACVERSION 191 fprintf (logfile, "%08lX (%04ld) | %08lX | %s | %s\n", (unsigned long) ticks, (ticks - lastticks), idthread, category, str); 192 #endif 193 194 lastticks = ticks; 195 196 fflush (logfile); 197 }/*logtofile*/ 198 199 200 static void logtoaboutwindow (char *str) { 201 202 bigstring bs; 203 204 copyctopstring (str, bs); 205 206 aboutsetmiscstring (bs); 207 }/*logtoaboutwindow*/ 208 209 210 static void logtodialog (char *str) { 211 212 }/*logtodialog*/ 213 214 215 static void logtodebugger (char *str) { 216 217 bigstring bs; 218 219 copyctopstring (str, bs); 220 221 DebugStr (bs); 222 }/*logtodebugger*/ 223 224 225 static void logtotargets (char *str, long targetflags, char *category) { 226 227 if (flreentering) 228 return; 229 230 flreentering = true; 231 232 if (targetflags & LAND_LOGTARGET_FILE) 233 logtofile (str, category); 234 235 if (targetflags & LAND_LOGTARGET_ABOUT) 236 logtoaboutwindow (str); 237 238 if (targetflags & LAND_LOGTARGET_DIALOG) 239 logtodialog (str); 240 241 if (targetflags & LAND_LOGTARGET_DEBUGGER) 242 logtodebugger (str); 243 244 flreentering = false; 245 }/*logtotargets*/ 246 247 248 void logmessage (char *msg, char *file, long line, long targetflags, char *category) { 249 250 char str[400]; 251 252 str[0] = 0; 253 254 sprintf (str, "%s [%s,%ld]", msg, file, line); 255 256 logtotargets (str, targetflags, category); 257 }/*logmessage*/ 258 259 260 long logassert (char *expr, char *file, long line, long targetflags, char *category) { 261 262 char str[400]; 263 264 str[0] = 0; 265 266 sprintf (str, "Assertion failed: %s [%s,%ld]", expr, file, line); 267 268 logtotargets (str, targetflags, category); 269 270 return (0); 271 }/*logassert*/ 272 273 274 void logstartup () { 275 276 /*perhaps get location of app here, so we can more precisely place our log file*/ 277 278 }/*logstartup*/ 279 280 281 void logshutdown () { 282 283 if (logfile != NULL) 284 fclose (logfile); 285 }/*DBTRACKERCLOSE*/ 286 287 288 289 290 291

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.